解题思路:使用字符串处理函数。字符串的输入输出用gets()和puts()函数。
注意事项:字符数组传参注意传递指针
参考代码:
#include<stdio.h>
#include<string.h>
#define len 1024
void swap(char *x, char *y);
int main(){
char x[len], y[len], z[len];
gets(x);
gets(y);
gets(z);
if(strcmp(x, y)>0){
swap(x, y);
}
if(strcmp(x, z)>0){
swap(x, y);
}
if(strcmp(y, z)>0){
swap(x, z);
}
puts(x);
puts(y);
puts(z);
}
void swap(char *x, char *y){
char tem[len];
strcpy(tem, x);
strcpy(x, y);
strcpy(y, tem);
}
0.0分
0 人评分