[求助]编程求助
不知道是哪个地方出错了,我输入2,5,3,显示最大数字是3,各位帮我看看,谢谢#include <stdio.h>
void main()
{ int a,b,c,max;
printf ("please input a,b,c:\n");
scanf ("%d,%d,%d",&a,&b,&c);
max=a;
if (max<b);
max=b;
if (max<c);
max=c;
printf ("The lagest number is %d",max);
}
[此贴子已经被作者于2006-8-2 10:53:09编辑过]
----------------解决方案--------------------------------------------------------
if();==>if()
去掉;
----------------解决方案--------------------------------------------------------
谢谢,知道了
----------------解决方案--------------------------------------------------------
if (max<b);
if (max<c);
如果你的输入没错的话,就应该是这2句多了2个分号";"
可以去掉44
----------------解决方案--------------------------------------------------------
编译可以通过,但判断语句是无效的。判断或的语句是空语句。
所以你的程序等同于做多次赋值。当然输出的是最后一个值3。
----------------解决方案--------------------------------------------------------
#include"stdio.h"
main()
{
int a,b,c;
int max;
printf("plase three number");
scanf("%d,%d,%d",&a,&b,&c);
if (a>b)
max=a;
else
max=b;
else if(max>c?max:c)
printf("max=%d",max);
}
那位大哥给看看小弟肤浅请教一下
----------------解决方案--------------------------------------------------------
以下是引用asx4560在2006-8-2 21:10:28的发言:
#include"stdio.h"
main()
{
int a,b,c;
int max;
printf("plase three number");
scanf("%d,%d,%d",&a,&b,&c);
if (a>b)
max=a;
else
max=b;
else if(max>c?max:c)
printf("max=%d",max);
}
那位大哥给看看小弟肤浅请教一下
#include"stdio.h"
main()
{
int a,b,c;
int max;
printf("plase three number");
scanf("%d,%d,%d",&a,&b,&c);
if (a>b)
max=a;
else
max=b;
else if(max>c?max:c)
printf("max=%d",max);
}
那位大哥给看看小弟肤浅请教一下
#include"stdio.h"
main()
{
int a,b,c;
int max;
printf("plase three number");
scanf("%d,%d,%d",&a,&b,&c);
if (a>b)
max=a;
else
max=b;
printf("max=%d",(max>c?max:c));
}
----------------解决方案--------------------------------------------------------
#include"stdio.h"
main()
{
int a,b,c;
int max;
printf("plase three number");
scanf("%d,%d,%d",&a,&b,&c);
if(a<b)
{
a=b;
}
if(a<c)
{
a=c;
}
printf("max=%d\n",a);
}
这样就可以了 你最后那里的if 前面的 else不能用那样语法不对
----------------解决方案--------------------------------------------------------
错了吧
else
max=b;
else if(max>c?max:c)
两个 else
----------------解决方案--------------------------------------------------------
难怪怎么卡
----------------解决方案--------------------------------------------------------