参考代码:
#include<iostream> #include<cstring> using namespace std; int main() { //freopen("data.in.txt","r",stdin); //freopen("data.out.txt","w",stdout); string str="0"; string str1; int n; cin>>n; if(n==0)//0是这个题目的陷阱 { cout<<"0"<<endl; return 0; } while(n--) { str1=""; for(int i=0;i<str.length();i++) { if(str[i]=='0') str1+="1"; else if(str[i]=='1') str1+="01"; //cout<<str1<<endl; } //cout<<str.length()<<endl; str=str1; } cout<<str1<<endl; return 0; }
0.0分
0 人评分