解题思路:
直接用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 人评分
WU-判定字符位置 (C++代码)浏览:1406 |
简单的a+b (C语言代码)浏览:817 |
C语言程序设计教程(第三版)课后习题1.5 (C语言代码)浏览:474 |
局部变量作函数返回值的问题浏览:981 |
C语言程序设计教程(第三版)课后习题9.8 (C语言代码)浏览:616 |
C语言程序设计教程(第三版)课后习题11.1 (C语言代码)浏览:489 |
矩形面积交 (C语言代码)浏览:1314 |
C语言程序设计教程(第三版)课后习题3.7 (C语言代码)浏览:573 |
C二级辅导-分段函数 (C语言代码)浏览:761 |
C语言程序设计教程(第三版)课后习题6.4 (C语言代码)浏览:681 |