#include <conio.h> #include <stdio.h> #include <string.h>
void fun( char *a, char *b, char *c ) { int i, j; char ch; i = 0; j = strlen(b)-1;
while (______)/*本人把此处填充i<j即可输出a4b3c2d1efg但填充b[i]<b[j]就不能实现逆序本人不解?高手指点*/ { ch = b[i]; b[i] = b[j]; b[j] = ch; i++; j--; } while ( *a || *b ) { if ( *a ) { *c = *a; c++; a++; } if ( *b ) { *c = *b; c++; b++; } }
*c= '\0'; }
main() { char s1[100],s2[100],t[200]; clrscr(); printf("\nEnter s1 string : "); scanf("%s",s1); printf("\nEnter s2 steing : "); scanf("%s",s2); fun( s1, s2, t ); printf("\nThe result is : %s\n", t ); } 其功能是:使s2数组中的字符逆序然后于s1中的字符交叉然后赋于t数组。例如: s2=1234 s1=abcdefg 则t=a4b3c2d1efg