Bosses, c language code process
CodePudding user response:
Three character array, and the third is used to save as a result, increasing cycle have a variable, when + 1 on the interval to third in the second array element in the array, or put the first array
Just general train of thought, can place a lot of improvement
CodePudding user response:
1/f, reference and 蘤 old crepe response: three character array, and the third is used to save as a result, increasing cycle have a variable, when + 1 on the interval to third in the second array element in the array, or put the first array Just general train of thought, can improve the place quite a few Please have a look at the core code process CodePudding user response:
# include & lt; Stdio. H> # include & lt; String. H> Int main () { Char string1 [101]={0};//input string 1 Char string2 [101]={0};//input string 2 Char string [201]={0};//output string Char * long_string=NULL; Char * short_string=NULL; Int str1_len=0;//the length of a string of 1 Int str2_len=0;//the length of the string 2 Int result=0;//insert interval int count=0; Int index=0;//string string index Int short_index=0;//a long string of index Int long_index=0;//the shorter string index The scanf (" % s ", string1); The scanf (" % s ", string2); The length of the string//o Str1_len=strlen (string1); Str2_len=strlen (string2); //if only input a string, the end If (str1_len==0 | | str2_len==0) return 0; //is the length of the two strings, to make sure the insert spacing result If (str1_len & gt;=str2_len) { Result=str1_len/str2_len; Long_string=string1; Short_string=string2; } else { Result=str2_len/str1_len; Long_string=string2; Short_string=string1; } While (long_string [long_index]!='\ 0') { String [index]=long_string [long_index]; + + long_index; + + index; + + count; If (count==result) { //if you have inserted the result of the long string characters Count=0; If (short_string [short_index]!='\ 0') { //insert short strings of one character String [index]=short_string [short_index]; + + index; + + short_index; } } } //output complete string Printf (" % s \ n ", string); return 0; } Idea: to find out the length of the two strings, and insert the interval, insert the shorter string to a long string, program wrote a detailed annotation, don't understand the place can again ask, hope to adopt! CodePudding user response:
I hope it can help you: https://blog.csdn.net/it_xiangqiang/category_10581430.html I hope it can help you: https://blog.csdn.net/it_xiangqiang/category_10768339.html