#include <stdio.h>
int main()
{
float A;
printf("Pls write the decibel\n");
scanf("%f",&A);
if (49<A,60>A)
{printf("quiet\n");}
else if (70>A,59<A)
{printf("Anoying\n");}
else if (80>A,69<A)
{printf("to Anoying\n");}
else if (90>A,79<A)
{printf("Very Anoying\n");}
else if (101>A,89<A)
{printf("Extreamly Anoying\n");}
else if (A>100)
{printf("You Are Dead\n");}
else if (50>A);
{printf("To Low\n");}
return 0;
}
让我说我写了100多封信,它说的太低了,同时又烦人,但没有一个是对的,我该怎么办?
谢谢
答案 0 :(得分:0)
else if (50>A);
后有一个分号,以
语句,以便无论如何执行下一个printf
。 &&
)而不是逗号运算符
在您的条件中。修改后的程序将是:
#include <stdio.h>
int main()
{
float A;
printf("Pls write the decibel\n");
scanf("%f",&A);
if (49<A && 60>A)
{printf("Quiet\n");}
else if (70>A && 59<A)
{printf("Annoying\n");}
else if (80>A && 69<A)
{printf("Too Annoying\n");}
else if (90>A && 79<A)
{printf("Very Annoying\n");}
else if (101>A && 89<A)
{printf("Extremely Annoying\n");}
else if (A>100)
{printf("You Are Dead\n");}
else if (50>A)
{printf("Too Low\n");}
return 0;
}
输出:
Pls write the decibel
101
You Are Dead