7.11复习题
- a. false
b. true
c. false
a. number >= 90 && number < 100
b. ch != 'q' && ch != 'k'
c. (number >= 1 && number <= 9) && number != 5
d. number < 1 || number > 9
- 修改后的程序如下
#include <stdio.h>
int main(void)
{
int weight, height;
scanf("%d %d", &weight, &height); //修改
if (weight < 100 && height > 64)
if (height >= 72)
printf("You are very tall for your weight. \n");
else //修改
printf("You are tall for your weight. \n");
else if (weight > 300 && height < 48) //修改
printf(" Your are quite short for your weight. \n"); //修改
else
printf("Your weight is ideal. \n");
return 0;
}
重点是,else 与 离它最近的 if 匹配, 从上向下看