BlackInk 发表于 2008-3-21 15:42:55

测试LAVA程序。。。死活不通过。。。

#include <stdio.y>
#include <math.y>
void main()
{
int a,b,c;
printf("请输入a和b:");
scanf("%d %d",&a,&b);
c=a-b;
if (c<0)
printf("%d<%d",a,b);
if (c>0)
printf("%d>%d",a,b);
if (c==0)
printf("%d=%d",a,b);
}

TYCY 发表于 2008-3-21 17:54:01

出错了吗?
提示什么?

yan 发表于 2008-3-21 18:12:17

LZ请看看stdio.y的说明文档,这里的scanf与C语言的scanf的使用方法是不同的!
正确的程序是:#include <stdio.y>
#include <math.y>
void main()
{
        int a, b, c;

        scanf("请输入a和b:", "%2d%2d", &a);
        c = a - b;
        if (c < 0) printf("%d < %d", a, b);
        else if (c > 0) printf("%d > %d", a, b);
        else printf("%d = %d", a, b);
}

TYCY 发表于 2008-3-21 18:16:47

yan那样写,LZ不知道明白不?
你还是在 &a后面加个 &b算了

BlackInk 发表于 2008-3-21 21:59:12

哦。。。谢谢yan了。。。
页: [1]
查看完整版本: 测试LAVA程序。。。死活不通过。。。