
C语言比较三个数大小
首先比较第一个数和第二个数的大小,如果第一个数大于第二个数,则将第一个数和第二个数互换,不大于则不作处理;然后将第二个数和第三个数比较,同样,若大于则将它们互换;最后比较完以后,最后一个数就是最大的。

代码
#include<stdio.h>
//#include<windows.h>
void main()
{
int max3(int a,int b,int c);
int a,b,c,result;
printf("Pleaseenterthreenumber:n");
scanf("%d,%d,%d",&a,&b,&c);
result=max3(a,b,c);
printf("Themaxofthreenumberis%d:n",result);
//system("pause");
}
int max3(int a,int b,int c)
{
int x,z;
if(a>b) x=a;
else x=b;
if(x>c) z=x;
else z=c;
return z;
}登录后复制推荐教程:《C#》
以上就是C语言比较三个数大小的详细内容,更多请关注靠谱客其它相关文章!

最后
以上就是疯狂白昼最近收集整理的关于C语言比较三个数大小的全部内容,更多相关C语言比较三个数大小内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复