编写一个c程序,输入a,b,c三个值,输出其中最大者,最小值,次大者
答案:2 悬赏:50
解决时间 2021-02-03 15:33
- 提问者网友:失败的占卜者
- 2021-02-03 07:18
编写一个c程序,输入a,b,c三个值,输出其中最大者,最小值,次大者
最佳答案
- 二级知识专家网友:颜值超标
- 2021-02-03 08:43
#include<stdio.h>
main()
{
int a,b,c,t=0;
printf("Please enter a,b,c:");
scanf("%d%d%d",&a,&b,&c);
if(a<b){t=a;a=b;b=t;}
if(a<c){t=a;a=c;c=t;}
if(b<c){t=b;b=c;c=t;}
printf("the result is %d %d %d\n",a,b,c);
}
main()
{
int a,b,c,t=0;
printf("Please enter a,b,c:");
scanf("%d%d%d",&a,&b,&c);
if(a<b){t=a;a=b;b=t;}
if(a<c){t=a;a=c;c=t;}
if(b<c){t=b;b=c;c=t;}
printf("the result is %d %d %d\n",a,b,c);
}
全部回答
- 1楼网友:冷态度
- 2021-02-03 09:47
int biggest(int a, int b, int c)
{
int t = a;
if(t < b) t = b;
if(t < c) t = c;
return t;
}
如果a,b,c是类,需要自己重载比较函数就行了^_^
我要举报
如以上问答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯