初学C语言,还望见谅;以前写过if语句,今天写if语句的嵌套;
int main()
{
int iDay;
int Monday=1,Tuesday=2,Wednesday=3,Turesday=4,Firday=5,
Saturday=6,Sunday=7;
printf("Enter a day of a week to get course\n");
scanf("%d",&iDay);
if(iDay>Firday)
{
if(iDay==Saturday)
{
printf("go shopping with friends\n");
}
else
{
printf("at home with families\n");
}
}
else
{
if(iDay==Monday)
{
printf("have a meeting with company\n");
}
else
{
printf("working with partner\n");
}
}
return 0;
}
这就是比较简单的嵌套,如有偏颇之处,还望见谅;