題目描述:墓碑上有2行字符串,其中第一個串的長度為偶數,現在要求把第2個串插入到第一個串的正中央,如此便能開啟墓碑進入墓中。 Input 輸入數據首先給出一個整數n,表示測試數據的組數。 然后是n組數據,每組數據2行,每行一個字符串,長度大于0,小于50,并且第一個串的長度必為偶數。 Output 請為每組數據輸出一個能開啟古墓的字符串,每組輸出占一行、 #include #include #include #include using namespace std; int main() { char s1[105],s2[105]; int len1,len2,n,i,j; while(scanf(“%d”,&n)!=EOF) { getchar();//處理字符串注意用getchar();接收一下 while(n–) { gets(s1); gets(s2); len1=strlen(s1); len2=strlen(s2); for( i=0;i< len1;i++) {cout<< s1[i]; if(i==len1/2-1) for(j=0;j< len2;j++) cout<< s2[j];
} cout<<"/n"; }}return 0;}新聞熱點
疑難解答