C语言有两种选择语句:(要会画流程图)
if语句
switch语句
switch语句的一般形式:
switch(表达式)
{
case 常量:语句
case 常量:语句
、、、、、、、、、
case 常量 :语句
case 常量 :语句
default:语句
}
例题4.8 判断闰年 (什么时候是闰年)
#include<stdio.h>
int main() {
int year;
scanf("%d", &year);
if (year % 4 == 0 && year % 100 != 0)
{
printf("%d is a leap year!\n", year);
}
else if (year % 400 == 0) {
printf("%d