如何半路中断此程序
程序说明:输入年月日,判断出这一天是这一年的第几天#include <stdio.h>
void main( )
{
int day, month, year, sum, leap;
printf("please input year,month,day\n");
scanf("%d %d %d",&year,&month,&day);
switch(month)
{
case 1:sum=0;break;
case 2:sum=31;break;
case 3:sum=59;break;
case 4:sum=90;break;
case 5:sum=120;break;
case 6:sum=151;break;
case 7:sum=181;break;
case 8:sum=212;break;
case 9:sum=243;break;
case 10:sum=273;break;
case 11:sum=304;break;
case 12:sum=334;break;
default:printf("data error\n");/*输入的月大于12*/
}
sum=sum+day;
if(year%400==0||(year%4==0&&year%100!=0))/*是否为闰年*/
leap=1;
else
leap=0;
if(leap==1&&month>2)/*若是闰年且月份大于2*/
sum++;
printf("it is the %d day.\n",sum);
}
问题:若输入1983 13 21,则输出结果为data error
it is the -858993439 day.
请教:如何发现month大于12时,即输出data error ,然后结束程序。谢谢!