其他分享
首页 > 其他分享> > C语言 6.0

C语言 6.0

作者:互联网

初学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;
}
这就是比较简单的嵌套,如有偏颇之处,还望见谅;

标签:Monday,int,iDay,6.0,Firday,C语言,printf,else
来源: https://blog.51cto.com/15098536/2621897