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

代码
立即学习“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语言比较三个数大小的详细内容,更多请关注php中文网其它相关文章!
C语言怎么学习?C语言怎么入门?C语言在哪学?C语言怎么学才快?不用担心,这里为大家提供了C语言速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号