题目链接:http://codeup.cn/problem.php?cid=100000569&pid=9
题目描述
从键盘上输入3个字符串,求出其中最大者。
输入
输入3行,每行均为一个字符串。
输出
一行,输入三个字符串中最大者。
样例输入
England
China
America
样例输出
England
代码
#include<stdio.h>
#include<string.h>
int main(){
char s1[10], s2[10], s3[10], smax[10];
gets(s1);
gets(s2);
gets(s3);
strcpy(smax, s1); // 字符数组不能直接用 smax = s1, 要用strcpy()函数
if(strcmp(s2, smax) > 0)
strcpy(smax, s2);
if(strcmp(s3, smax) > 0)
strcpy(smax, s3);
puts(smax);
return 0;
}