#include
#include
#include
void main()
{
char buf1[100],buf2[100],buf3[200];
cout<<"please enter buf1: "<
cout<<"please enter buf2: "<
char *p1=buf1;
char *p2=buf2;
char *p3=buf3;
int m1,m2,m3;
m1=strlen(buf1);
m2=strlen(buf2);
m3=m1+m2;
for (int i=0;i
*(p3+i)=*(p1+i/2);
*(p3+i+1)=*(p2+m2-1-i/2);
cout<<*(p3+i)<<*(p3+i+1);
}
cout<
。。。。。2个字符串长度一样。。。。
#include
#include
#include
using namespace std;
void main()
{
char* ch1;
char* ch2;
string str1, str2;
cin>>str1>>str2;
ch1 = (char*)str1.c_str();
reverse(str2.begin(), str2.end());
ch2 = (char*)str2.c_str();
int n1 = str1.length();
int n2 = str2.length();
char* ch3 = new char[n1 + n2];
memset(ch3, 0, n1 + n2);
char* chBegin = ch3;
int i1 = 0, i2 = 0;
while (i1 < n1 || i2
if (i1
*ch3 = *ch1;
ch3++;
ch1++;
i1++;
}
if (i2 < n2)
{
*ch3 = *ch2;
ch3++;
ch2++;
i2++;
}
}
*ch3 = 0;
ch3 = chBegin;
cout<<"结果为:"<
delete [] ch3;
system("pause");
}