-2
#include <stdio.h>
#include <stdlib.h>
int main(int argc, const char * argv[])
{

    int num1, num2, num3;

    printf("Please enter three numbers from the following combinations.\n 1 4 3, 3 3 9,3 3 4, 7 6 3");

    scanf("%d %d %d", &num1, &num2, &num3);
    {
    if ((num1 == 1) && (num2 == 4) && (num3 ==3))
        printf("I love you too :)\n");

    if ((num1 == 3) && (num2 == 3) && (num3 ==9))
        printf("YOU ARE BEAUTIFUL !\n");

    if ((num1 == 3) && (num2 == 3) && (num3 == 4))
        printf("You are best!\n");

    if ((num1 == 7) && (num2 == 6) && (num3 == 3))
        printf("Anubhav misses you !\n");

// 现在我希望它去 else 如果上面是假的,但它也这样做,即使它是真的
else printf("You enter %d %d %d\n", num1 ,num2, num3); printf("这个业余程序员没有收录:(\n");

    }

printf("I still remember about the calculator :D\n");

return 0;
4

1 回答 1

0

如果我正确地阅读了您的问题...您的每个“if”语句(在第一个之后)都需要是 else-if。而且由于结尾的“else”子句中有多行,因此您需要将这两行括在大括号中。像这样:

if ....
else if ((num1 == 3) && (num2 == 3) && (num3 == 4))
    printf("You are best!\n");
else if ((num1 == 7) && (num2 == 6) && (num3 == 3))
    printf("Anubhav misses you !\n");
else {
    printf("You entered %d %d %d\n", num1 ,num2, num3); 
    printf("This has not been included by this amateur programmer :(\n");
}
于 2013-04-02T13:10:46.517 回答