#include<iostream>
using namespace std;
#define MAXLEN 255
typedef struct
{
char ch[MAXLEN + 1];
int length;
} SString;
void insert(SString&S, SString T, int pos)
{
SString Stemp;
Stemp.length = S.length - pos;
if(Stemp.length>=0)
{
S.length = T.length + S.length;
int ltemp;
ltemp = pos;
for (int i = 0; i < Stemp.length; i++)
{
Stemp.ch[i] = S.ch[ltemp];
ltemp++;
}
for (int i = 0; i < T.length; i++)
{
S.ch[pos]=T.ch[i];
pos++;
}
for (int i = 0; i < Stemp.length; i++)
{
S.ch[pos] = Stemp.ch[i];
pos++;
}
}
else
{
int p = S.length;
S.length = T.length + S.length;
for (int i = 0; i < T.length; i++)
{
S.ch[p] = T.ch[i];
p++;
}
}
}
int StrLength(SString S)
{
return S.length;
}
void CreateStr(SString &S)
{
int n;
cin >> n;
for (int i = 0; i < n; i++)
cin >> S.ch[i];
S.length = n;
cout << endl;
}
void OutStr(SString &S)
{
cout << "插入后的新字符串的长度及字符为:" << S.length << " ";
for (int i = 0; i < S.length; i++)
cout << S.ch[i];
cout << endl;
}
int main()
{
SString s,t;
int n;
cout << "输入主字符串的长度及字符:";
CreateStr(s);
cout << "输入要插入的字符串的长度及字符:";
CreateStr(t);
cout << "输入插入的位置:";
cin >> n;
cout << endl;
insert(s, t, n);
OutStr(s);
}