#include <stdio.h>
int main ()
{
char odd, even, answer;
int x = -16;
printf("Choose, even or odd?");
scanf("%c", &answer);
if (answer == odd)
{
while (x < 15)
{
x++;
if (!(x % 2 == 1) && !(x % 2 == -1))
continue;
printf("%d\n", x);
}
printf("Look! Odd numbers!\n");
return 0;
}
else if (answer == even)
{
while (x < 15)
{
x++;
if ((x % 2 == 1) && (x % 2 == -1))
continue;
printf("%d\n", x);
}
printf("Look! Even numbers!\n");
return 0;
}
else
{
printf("That's not a valid response");
return 0;
}
}
抱歉,我是新手,遇到了问题。
输出总是以“else”选项结束。
if 和 else if 的布尔值我做错了什么?