赌圣2上海滩周星驰国语:帮忙用C语言编个程序:输入a,b,c3个值,输出其中的最大者

来源:百度文库 编辑:中科新闻网 时间:2024/04/28 08:06:27
我是学人力资源管理的,想自学C语言,很多都不会。麻烦各位帮帮忙阿。

TMD!我的最简单!用三目运算最简单!
#include<stdio.h>
main()
{
int a,b,c;
scanf("%d,%d,%d",&a,&b,&c);
printf("(a>b&&a>c)? a: b>a&&b>c? b:c");
}
如此而已!何必上面那么复杂!!!!!!!!!!!!!!!

#include"stdio.h"
int main()
{
int a,b,c,max;
scanf("%d%d%d",&a,&b,&c);
max=a;
if(b>max){
max=b;
if(c>max)
max=c; }
printf("max=%d",max);
}

这种方法不是很好~
考虑到你是初学!~编个简单的
最好是用数组起泡法
一楼的方法太烦琐,不推荐使用~而且写的是错的~那个是比较三个数大小时才用!而楼主问的是取三个数中的最大值
二楼的方法不适合初学的人训练逻辑思维能力
我用的方法最适合你!

1搂那个有很多错的,上面算法复杂,下面是正确的,而且比较简单
main()
{ int a,b,c,max;
scanf("%d,%d,%d",&a,&b,&c);
max=a;
max=max>b?max:b;
max=max>c?max:c;
printf("max is %d \n",max);
}

#include<stdio.h>
main()
{ int a,b,c,n;
int t;
scanf("%c,%c,%c",&a,&b,&c);
if(a>b)
(a=t,a=b,b=t);
if(b>c)
(b=t,b=c,c=t);
else (c>a)
(c=t,c=a,a=t);
printf("max is %c \n" &n);
}

#include <stdio.h>

int main(){
int a; int b; int c;
printf("Enter the 1st number:");
scanf("%d", &a);
printf("Enter the 2nd number:");
scanf("%d", &b);
printf("Enter the 3rd number:");
scanf("%d", &c);

if (a>=b && a>=c)
printf("The Max Number is: %d\n", a);
else if (b>=a && b>=c)
printf("The Max Number is: %d\n", b);
else if (c>=a && c>=b)
printf("The Max Number is: %d\n", c);
else
return 0;
return 1;
}

我学的一楼的对于初学者最易理解!