问题及代码
Description
将字符串t插入到字符串s中,在位置pos后插入。不得使用字符串操作函数,输出组合成的字符串。
Input
输入两个字符串(t和s)和要插入的位置(pos)
Output
输出组合后的字符串
Sample Input
qwe
jij
3
Sample Output
jijqwe
/*烟台大学计算机学院 2016
作者: 马春澎
完成日期:2016年12月10日 */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main()
{
int pos,i,m,n;
char s[80],t[80];
gets(t);
gets(s);
scanf("%d",&pos);
n=strlen(t);
m=strlen(s);
for(i=0; i<pos; i++)
{
printf("%c",s[i]);
}
for(i=0; i<n; i++)
{
printf("%c",t[i]);
}
for(i=pos; i<m; i++)
{
printf("%c",s[i]);
}
return 0;
}
运算结果
知识点总结
字符串的应用
学习心得
要搞清楚是谁插到谁后面,刚开始很容易弄晕了。

本文介绍了一个简单的C语言程序,用于在指定位置将一个字符串插入到另一个字符串中,不使用任何内置字符串操作函数。通过示例输入输出展示程序的功能。
879

被折叠的 条评论
为什么被折叠?



