Liamcoder


私信TA

用户名:18817572995

访问量:9577

签 名:

Where there is a will, there is a way.

等  级
排  名 1868
经  验 2487
参赛次数 2
文章发表 11
年  龄 0
在职情况 学生
学  校 上海师范大学
专  业 计算机科学与技术

  自我简介:

屌丝程序狗

解题思路:使用字符串处理函数。字符串的输入输出用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 人评分

  评论区