搜索
查看: 1988|回复: 4

C语言抢答[08.16]

[复制链接]
发表于 2012-8-16 16:39:20 | 显示全部楼层 |阅读模式
16啊哈币
[ 本帖最后由 virfyf 于 2012-8-16 16:43 编辑 ]\n\n
下列代码会输出c>b>a吗?为什么.
若要让它输出c>b>a, 要如何改动代码?
[mw_shl_code=c,true]
#include <stdio.h>
int main()
{
        int a=1,b=2,c=3;
        if(c>b>a)
                printf("c>b>a");
        return 0;
}[/mw_shl_code]

最佳答案

查看完整内容

不能,因为判断语句有误,正确代码:
发表于 2012-8-16 16:39:21 | 显示全部楼层
本帖最后由 =student= 于 2012-8-21 13:10 编辑

不能,因为判断语句有误,正确代码:
  1. #include <stdio.h>
  2. int main()
  3. {
  4.         int a=1,b=2,c=3;
  5.         if(c>b && c>a && b>a)
  6.                 printf("c>b>a");
  7.         sleep(5000);
  8.         return 0;
  9. }
复制代码
 楼主| 发表于 2012-8-17 16:39:43 | 显示全部楼层
=student= 发表于 2012-8-17 12:41
不能,因为判断语句有误,正确代码:
#include
int main()

判断语句为什有误?
发表于 2012-8-17 16:49:24 | 显示全部楼层
virfyf 发表于 2012-8-17 16:39
判断语句为什有误?

貌似c语言不能这么写if(c>b>a)
 楼主| 发表于 2012-8-17 17:17:58 | 显示全部楼层
=student= 发表于 2012-8-17 16:49
貌似c语言不能这么写if(c>b>a)

可以这么写
你试一试
printf("%d %d %d",c>b,b>a,c>b>a);
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

广播台
特别关注
快速回复 返回顶部 返回列表