Liamcoder


私信TA

用户名:18817572995

访问量:9579

签 名:

Where there is a will, there is a way.

等  级
排  名 1872
经  验 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 人评分

看不懂代码?想转换其他语言的代码? 或者想问其他问题? 试试问问AI编程助手,随时响应你的问题:

编程语言转换

万能编程问答

代码解释器

  评论区