解题思路:
直接用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语言代码)错误???浏览:570 |
2006年春浙江省计算机等级考试二级C 编程题(2) (C语言代码)浏览:473 |
C语言程序设计教程(第三版)课后习题6.6 (C语言代码)浏览:350 |
【计算两点间的距离】 (C语言代码)浏览:1497 |
C语言程序设计教程(第三版)课后习题3.7 (C语言代码)浏览:262 |
C语言程序设计教程(第三版)课后习题9.10 (C语言代码)浏览:841 |
字符串输入输出函数 (C语言代码)浏览:2495 |
单词个数统计 (C语言代码)浏览:1014 |
陶陶摘苹果2 (C语言代码)浏览:602 |
简单的a+b (C语言代码)浏览:560 |