解题思路:
直接用string提供的插入模板str.insert(下标,要插入的字符串);
注意事项:
参考代码:
#include <iostream>
#include <deque>
#include <string>
#include <iterator>
#include <vector>
#include <numeric>
#include <cmath>
#include <cstdlib>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <string.h>
using namespace std;
int main()
{
string str="0";
int n;
cin>>n;
for(int i=0;i<n;i++){
for(int j=0;j<str.size();j++){
if(str[j]=='0'){
str[j]='1';
}
else if(str[j]=='1')
{
str.insert(j,"0");
j++;
}
}
}
cout<<str<<endl;
return 0;
}
0.0分
0 人评分
C语言程序设计教程(第三版)课后习题7.5 (C语言代码)浏览:605 |
C二级辅导-进制转换 (C语言代码)浏览:615 |
C语言程序设计教程(第三版)课后习题6.4 (C语言代码)浏览:738 |
C语言训练-亲密数 (C语言代码)浏览:682 |
C语言程序设计教程(第三版)课后习题9.3 (C语言代码)浏览:668 |
C语言程序设计教程(第三版)课后习题1.5 (C语言代码)浏览:606 |
1013题解浏览:553 |
循环入门练习5 (C语言代码)浏览:837 |
剪刀石头布 (C++代码)浏览:1707 |
震宇大神的杀毒软件 (C语言代码)浏览:1079 |