描述
将字符串t插入到字符串s中,在位置pos后插入。不得使用字符串操作函数,输出组合成的字符串。
输入
输入两个字符串(t和s)和要插入的位置(pos)
输出
输出组合后的字符串
输入样例 1
qwe
jij
3
输出样例 1
jijqwe
#include<stdio.h>
#include<string.h>
int main(){
char t[100],s[100];
int pos;
gets(t);
gets(s);
scanf("%d",&pos);
int tc,sc;
tc = strlen(t);
sc = strlen(s);
int i,j;
for(i = tc+pos,j=pos;j<sc;j++,i++){
s[i] = s[j];
}
for(j=0,i=pos;j<tc;j++,i++){
s[i] = t[j];
}
for(j=0;j<tc+sc;j++){
printf("%c",s[j]);
}
}