易码技术论坛

 找回密码
 加入易码
搜索
查看: 1104|回复: 4

[求助] 测试LAVA程序。。。死活不通过。。。

[复制链接]
发表于 2008-3-21 15:42:55 | 显示全部楼层 |阅读模式
#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);
}
发表于 2008-3-21 17:54:01 | 显示全部楼层
出错了吗?
提示什么?
发表于 2008-3-21 18:12:17 | 显示全部楼层
LZ请看看stdio.y的说明文档,这里的scanf与C语言的scanf的使用方法是不同的!
正确的程序是:
  1. #include <stdio.y>
  2. #include <math.y>
  3. void main()
  4. {
  5.         int a, b, c;

  6.         scanf("请输入a和b:", "%2d%2d", &a);
  7.         c = a - b;
  8.         if (c < 0) printf("%d < %d", a, b);
  9.         else if (c > 0) printf("%d > %d", a, b);
  10.         else printf("%d = %d", a, b);
  11. }
复制代码
发表于 2008-3-21 18:16:47 | 显示全部楼层
yan那样写,LZ不知道明白不?
你还是在 &a后面加个 &b算了
 楼主| 发表于 2008-3-21 21:59:12 | 显示全部楼层
哦。。。谢谢yan了。。。
您需要登录后才可以回帖 登录 | 加入易码

本版积分规则

Archiver|手机版|小黑屋|EMAX Studio

GMT+8, 2024-4-20 18:48 , Processed in 0.011082 second(s), 18 queries .

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表