输入三个字符串,按由小到大输出。。。
程序代码:
#include < stdio.h > #include < stdlib.h > #include < string.h > void main ( ) { void swap ( char *p1,char *p2, char *p3); char *p1, *p2, *p3; int i; char str[3][20]; for ( i = 0; i < 3; i++ ) gets ( str[i] ); p1 = str[0]; p2 = str[1]; p3 = str[2]; swap ( p1, p2, p3 ); printf ( "%s%s%s", *p1, *p2, *p3 ); system ( "pause" ); } void swp ( char *p1, char *p2, char *p3 ) { if ( strcmp ( p1,p2 ) > 0 ) strcpy ( p1, p2 ); if ( strcmp ( p1, p3 ) > 0 ) strcpy ( p1, p3 ); if ( strcmp ( p2, p3 ) > 0 ) strcpy ( p2, p3 ); return ; }我写的是这样的,但错了,