2274: 字符串插入
Description 将字符串t插入到字符串s中,在位置pos后插入。不得使用字符串操作函数,输出组合成的字符串。 Input 输入两个字符串(t和s)和要插入的位置(pos) Output 输出组合后的字符串 Sample Input** qwe jij 3 Sample Output jijqwe 参考解答:
#include<stdio.h>
int main()
{
char t[
100],s[
100],r[
200];
int pos,i=
0,j=
0;
gets(t);
gets(s);
scanf(
"%d", &pos);
while(s[i]!=
'\0'&&i<pos)
{
r[i]=s[i];
i++;
}
while(t[j]!=
'\0')
{
r[i+j]=t[j];
j++;
}
while(s[i]!=
'\0')
{
r[i+j]=s[i];
i++;
}
r[i+j]=
'\0';
puts(r);
return 0;
}