您的位置:首页 > 其它

精彩百例:exit()函数

2015-03-27 20:14 162 查看
# include <stdio.h>
# include <stdlib.h>

int main(void)
{
int month;
int day;

printf("please input the month number :");
scanf("%d", &month);

switch(month)
{
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12:
day = 31;//是大月的输出31天
break;
case 4:
case 6:
case 9:
case 11:
day = 30;//小月的输出30天
break;
case 2:
day = 28;//输出28天
break;
default:
exit(0);//退出程序
}
printf("\n2015.%d has %d days.\n", month, day);

return 0;
}
运行结果是:

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  c