求解求解!!请问 该程序显示无错误,为什么无论输入a>b还是b>a输出结果均为A>B??
#include<stdio.h>
void main()
{ int a,b;
printf("please input A,B: ");
scanf("%d,%d",&a,&b);
if(a!=b)
if(a>b)
printf("A>B\n");
else
printf("A<B\n");
else
printf("A=B\n");
}
#include<stdio.h>你的等价于
void main()
{ int a,b;
printf("please input A,B: ");
scanf("%d,%d",&a,&b);
if(a!=b)
{if(a>b)
printf("A>B\n");
else
printf("A<B\n");
}
else
printf("A=B\n");
}
#include<stdio.h>
void main()
{ int a,b;
printf("please input A,B: ");
scanf("%d,%d",&a,&b);
if(a!=b)
{if(a>b)
printf("A>B\n"); }//记住if和else 都是一个语句
else
printf("A<B\n");
else
printf("A=B\n");
}
int a, b;
printf("Please input A B:\n");
scanf("%d %d", &a, &b);
fflush(stdin);
if (a != b)
{
if (a > b)
printf("A > B\n");
else
printf("A < B\n");
}
else
printf("A = B\n");
#include<stdio.h>
int main(void)
{
int a,b;
printf("please input A,B:\n");
scanf("%d%d",&a,&b);
if(a!=b)
{
if(a > b)
printf("A > B\n");
else
printf("A < B\n");
}
else
printf("A = B\n");
return 0;
}