解题思路:使用字符串处理函数。字符串的输入输出用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 人评分
C语言考试练习题_一元二次方程 (C语言代码)浏览:768 |
十->二进制转换 (C语言代码)浏览:1326 |
【排队买票】 (C语言代码)浏览:940 |
C语言程序设计教程(第三版)课后习题6.6 (C++代码)浏览:647 |
Cylinder (C语言描述+详细分析)浏览:3347 |
杨辉三角 (C语言代码)浏览:500 |
C二级辅导-公约公倍 (C语言代码)浏览:536 |
DNA (C语言代码)浏览:835 |
幸运数 (C++代码)浏览:2967 |
C语言程序设计教程(第三版)课后习题5.7 (C语言代码)浏览:455 |