题目描述:
从键盘上输入3个字符串,求出其中最大者。
输入:
输入3行,每行均为一个字符串。
输出:
一行,输入三个字符串中最大者。
样例输入:
England
China
America
样例输出:
England
代码展示:
#include<stdio.h>
#include<string.h>
int main(void)
{
char a[50],b[50],c[50],*max;
int i,judge;
gets(a);
gets(b);
gets(c);
judge=strcmp(a,b);
if(judge>0)
max=a;
else
max=b;
judge=strcmp(max,c);
if(judge<0)
max=c;
printf("%s",max);
return 0;
}
收获:
巧用已有的函数,strcmp,比较大小,strlen,得到长度,