char * mergeAlternately(char * word1, char * word2){
int n1=strlen(word1),n2=strlen(word2);
char* temp=(char*)malloc(sizeof(char)*(n1+n2+1));
int index1=0,index2=0,index=0,tag=0;
while(index1<n1 && index2<n2){
if(tag==0){
temp[index++]=word1[index1++];
tag=1;
}else{
temp[index++]=word2[index2++];
tag=0;
}
}
if(index1<n1){
for(;index1<n1;index1++) temp[index++]=word1[index1];
}else{
for(;index2<n2;index2++) temp[index++]=word2[index2];
}
temp[n1+n2]=0;
return temp;
}
标签:int,char,交替,1768,word1,word2,字符串,n1
From: https://www.cnblogs.com/llllmz/p/18075809