编写程序,输入任意一个含有空格的字符串(至少10个字符),删除指定字符后输出该字符串。例如,输入“jiangsu123”和删除位置5,则输出“jiansu123”。
5条回答
- threenewbee 2016-02-18 13:40关注
#include <iostream> #include <string> using namespace std; int main() { char s1[100]; char s2[100]; int n = 0; cin.getline(s1, 100); cin.getline(s2, 100); cin >> n; int i; int ls2 = strlen(s2); for (i = strlen(s1); i >= n; i--) s1[i + ls2] = s1[i]; for (i = 0; i < ls2; i++) s1[n + i] = s2[i]; cout << s1 << endl; return 0; }
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 1无用 2
悬赏问题
- ¥50 汇编语言除法溢出问题
- ¥65 C++实现删除N个数据列表共有的元素
- ¥15 Visual Studio问题
- ¥15 state显示变量是字符串形式,但是仍然红色,无法引用,并显示类型不匹配
- ¥20 求一个html代码,有偿
- ¥100 关于使用MATLAB中copularnd函数的问题
- ¥20 在虚拟机的pycharm上
- ¥15 jupyterthemes 设置完毕后没有效果
- ¥15 matlab图像高斯低通滤波
- ¥15 针对曲面部件的制孔路径规划,大家有什么思路吗