字符串的插入
#include <iostream>
using namespace std;
//将t插入到s中 插入位置为pos(插在第pos个字符前)
void insert(char* s,char* t,int pos){
if(pos < 1 ) return ;
//TODO 求出字符串长度
int len1 = 0;
int len2 = 0;
while(s[len1] !='\0') len1++;
while(t[len2] !='\0') len2++;
//TODO 将s中pos位置向后移动len2个位置
for(int i = len1 - 1 ;i >= pos - 1;i--){
s[i+len2] = s[i];
}
//TODO 将t中的字符串写入到pos位置之前
int j = 0;
for(int i = pos - 1;i < pos - 1 + len2;i++){
s[i] = t[j++];
}
for (int i = 0; i < len1 + len2; ++i){
cout<<s[i];
}
cout<<endl;
}
int main(){
int pos;
cin>>pos;
while(pos !=0){
char a[200];
char b[100];
cin>>a>>b;
insert(a,b,pos);
// cout<<a<<endl;
cin>>pos;
}
}