谁能告诉我这段代码有什么问题吗?

标签 c compiler-errors

问题只是找到三个数字中最大的一个。 我很确定,但系统显示“线程 1;断点 2.1” PS:我使用的是xcode...... 谢谢!

#include <stdio.h>

int main()   {

    int a ;
    int b ;
    int c ;

    printf("Enter your first number\n") ;
    scanf("%d",&a) ;

    printf("Enter your second number\n") ;
    scanf("%d",&b);

    printf("Enter your third number\n") ;
    scanf("%d",&c) ;

    if (a>b & a>c) {
        printf("%d is greatest\n",a) ;
    }
    if (b>a & b>c) {
        printf("%d is greatest\n",b);
    }
    if (c>a & c>b) {
        printf("%d is greatest\n",c);
    }
    return 0 ;


}

最佳答案

使用逻辑&&代替按位&

if (a>b && a>c)

关于谁能告诉我这段代码有什么问题吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42179683/

相关文章:

c - 如何将这些字符沿字母表向下移动 3 个空格,而不进入字母表之外的其他字符?

swift - Swift泛型函数受类generic约束

java - 如何将值返回到二维数组?

具有预定大小的 C++ vector 抛出编译错误

c - 发送UDP广播后收到响应

C - 结构内指针的默认值

c - 最大 CreateProcessWithLogonW 和 NetUserAdd

c - 将前 10 个分数写入文件

c - '%s'期望参数类型为 'char *',但参数类型为 'int'

compiler-errors - 这个帕斯卡语法有什么问题?? - 导致编译器错误