条件判断
if-else
#include<stdio.h>
#include<stdlib.h>
int main()
{
int a, b;
a = ;
b = ;
if (a > b)//切记括号不能再加 ;号
{
printf("a is bigger\n");
}
else{
printf("b is bigger\n");
}
system("pause");
return ;
}
switch
#include<stdio.h>
#include<stdlib.h>
//输入一个月份, 输出该月份有多少天
int main()
{
int mon;
while (scanf("%d", &mon) != EOF)
{
switch (mon)
{
case :
case :
case :
case :
case :
case :
case :printf("month %d is 31 days\n", mon); break;
case :
case :
case :
case :printf("month %d is 30 days\n", mon); break;
case :printf("month %d is 28 days\n", mon); break;
default:printf("month error\n");
}
}
system("pause");
return ;
}