一道可以打表的水题
此题需要输出π的前n位, 因此可以通过打表的方式解决
答案字符串代码
输入为π的前10000位(AC数据), 不含除数字和空格外其他字符。 输出字符”/“结束输入
#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;
}参考输出代码:
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';
}
}