跳到正文

题解

π

Lyy11451467约 1 分钟
原文
文章信息与版本

文章信息

收录
2026年7月7日
更新
2026年7月7日
篇幅
约 1 分钟

版本

  1. v1当前

一道可以打表的水题

P1727

此题需要输出π的前n位, 因此可以通过打表的方式解决

another

答案字符串代码

输入为π的前10000位(AC数据), 不含除数字和空格外其他字符。 输出字符”/“结束输入

C++
#include<bits/stdc++.h>
using namespace std;
string s;
char c;
int main(){
	while(c!='/'){
		cin>>c;
		if(c==' '||c=='/')continue;
		s+=c;
	}
	system("cls");
	cout<<"string S="<<'"'<<s<<'"'<<";\n";
	return 0;
}

参考输出代码:

C++
void print(int n){
	cout<<"3.\n";
	for(int i=1;i<=n;i++){
		cout<<S[i-1];
		if(i%10==0)cout<<' ';
		if(i%50==0)cout<<'\n';
	}
}
原文