2017-02-11 98 views
-1

问题在于找到三个数字中最大的一个。 我很确定它,但系统显示'线程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 ; 


} 
+1

'(A> B&A> C)' - >'(A> B && A> C)'。逻辑和运算符='&&'。一个'&'是一个位和操作符。 –

+0

'&'和'&&'是两个不同的运算符。你用错了。 – DyZ

+0

你如何建立你的程序?你如何运行它?你给了什么输入?什么是完整的,完整的和未经编辑的输出(将其复制粘贴为文本)? –

回答

1

使用逻辑&& insted的按位&的。

if (a>b && a>c) 
1

你想用&&,但使用的是&代替。

if (a>b && a>c)

相关问题