输入5个字符串,输出其中最大的字符串。
输出格式: printf("Max is: %s\n", );
输入输出示例:括号内为说明,无需输入输出
输入样例:
peach
pear
melon
orange
berry
输出样例:
Max is: pear
#include<bits/stdc++.h>
using namespace std;
char* cmp(char p[],char q[]);
int main()
{
char a[100],b[100],c[100],d[100],e[100];
cin>>a;
cin>>b;
cin>>c;
cin>>d;
cin>>e;
printf("Max is: %s\n",cmp(cmp(cmp(cmp(a,b),c),d),e));
}
char* cmp(char p[],char q[])
{
if(strcmp(p,q)>0)
return p;
else return q;
}
原文链接: https://www.cnblogs.com/Haikon-C/p/12430724.html
欢迎关注
微信关注下方公众号,第一时间获取干货硬货;公众号内回复【pdf】免费获取数百本计算机经典书籍
原创文章受到原创版权保护。转载请注明出处:https://www.ccppcoding.com/archives/194034
非原创文章文中已经注明原地址,如有侵权,联系删除
关注公众号【高性能架构探索】,第一时间获取最新文章
转载文章受原作者版权保护。转载请注明原作者出处!