怎样比较3个数大小
#include<stdio.h>int main()
{
int a,b,c,z,max;
scanf("%d%d%d",&a,&b,&c);
if(a>b&&a>c)
return max=a;
if(b>a&&b>c)
return max=b;
if(c>a&&c>b)
return max=c;
z=max;
printf("a,b,c的最大值为%d",z);
}
为什么这样不行?
2010-11-18 17:00
程序代码:#include<stdio.h>
int main()
{
int a = 0 ,b = 0 ,c = 0,max = 0;
puts("Input 3 integers:");
scanf("%d%d%d",&a,&b,&c);
max = a;
if(max < b)
max = b;
if(max < c)
max = c;
printf("%d %d %d中最大的是%d\n",a,b,c,max);
return 0;
}

2010-11-18 17:13
2010-11-18 17:14
2010-11-18 17:15
2010-11-20 15:36
2010-11-20 15:36
程序代码:#include <stdio.h>
void main()
{
int max(int x,int y);
int a,b,c,_max;
printf("enter data:\n");
scanf("%d,%d,%d",&a,&b,&c);
_max=max(a,max(b,c));
printf("max=%d\n",_max);
}
int max(int x,int y)
{
int z;
if(x>y)
z=x;
else
z=y;
return z;
}调用函数,比较简便…
2010-11-20 17:39

2010-11-20 18:55
2015-07-21 10:19
2015-08-22 10:42