c程序输入三个值,输出最大值的问题?
就出来了12这个值,需要改哪里,求解答。
#include<stdio.h>
int main()
{
int a,b,c,max;
printf("please input a,b,c:\n");
scanf_s("%d,%d,%d", &a,&b,&c);
max=a;
if(max<b)
max=b;
if(max<c)
max=c;
printf("The laresr number is %d\n", max);
return 0;
} 展开
#include<stdio.h>
int main()
{
int a,b,c,max;
printf("please input a,b,c:\n");
scanf("%d,%d,%d", &a,&b,&c);
printf("The a number is %d\n", a);
printf("The b number is %d\n", b);
printf("The c number is %d\n", c);
printf("The max number is %d\n", max);
max=a;
printf("The maxa number is %d\n", max);
if(max<b)
max=b;
printf("The maxb number is %d\n", max);
if(max<c)
max=c;
printf("The maxc number is %d\n", max);
printf("The laresr number is %d\n", max);
return 0;
}
输入带逗号:
输入不带逗号
你可以每一步都把数据打印出来看看,是哪里出问题了,我这里运行起来没有问题。
int max(int a,int b,int c);
int main()
{
int a = 0,b = 0,c = 0,x;
scanf("%d %d %d",&a,&b,&c);
x=max(a,b,c);
printf("max=%d\n",x);
return 0;
}
int max(int a,int b,int c)
{
int d=a;
if(b>d)d=b;
if(c>d)d=c:
return d;
}