Void main ()
{
Int year;
Int the month, maxmonth=12;
Int day, maxday;
Printf (" please enter the year (1000 ~ 3000) ");
The scanf (" % d ", & amp; Year);
If (year<1000 | | year> 3000)
{
Printf (" input error! Please input the new! \n");
Printf (" please enter the year (1000 ~ 3000) ");
The scanf (" % d ", & amp; Year);
}
Printf (" please enter the month (1 ~ 12) ");
The scanf (" % d ", & amp; The month);
If (month<1 | | month> 12)
{
Printf (" input error! Please input the new! \n");
Printf (" please enter the month (1 ~ 12) ");
The scanf (" % d ", & amp; The month);
}
If (the month==4 | | the month 6==| | 9 month==| | the month==11)
Maxday=30;
Else if (the month==2)
{
If (year %==0 400 | | year % 4==0)
Maxday=28;
The else
Maxday=29;
}
The else
Maxday=31;
Printf (" please enter the day of (1 ~ 31) ");
The scanf (" % d ", & amp; Day);
If (day<1 | | day> Maxday)
{
Printf (" input error! Please input the new! \n");
Printf (" please enter the day of (1 ~ 31) ");
The scanf (" % d ", & amp; Day);
}
If (the month==maxmonth & amp; & Day==maxday)
{
Year=year + 1;
The month=1;
Day=1;
}
Else if (day==maxday)
{
The month=month + 1;
Day=1;
}
The else
Day=day + 1;
Printf (" the next day is on % d % d % d ", year, month, day);
getchar();
}
Press enter exit not compile the results automatically
CodePudding user response:
Look will go to the printf ah, you save compile?CodePudding user response:
Press the "Enter" key, the buffer will be "wrap" character, this will also be getchar () take, you can try call twice getchar (), or call system (" pause "); (need to include the header file # include & lt; Windows. H>)CodePudding user response:
# include
//void main ()
Int main ()
{
Int year;
Int the month, maxmonth=12;
Int day, maxday;
Printf (" please enter the year (1000 ~ 3000) ");
The scanf (" % d ", & amp; Year);
//if (year<1000 | | year> 3000)
While (year<1000 | | year> 3000)
{
Printf (" input error! Please input the new! \n");
Printf (" please enter the year (1000 ~ 3000) ");
The scanf (" % d ", & amp; Year);
}
Printf (" please enter the month (1 ~ 12) ");
The scanf (" % d ", & amp; The month);
//if (month<1 | | month> 12)
While (month<1 | | month> 12)
{
Printf (" input error! Please input the new! \n");
Printf (" please enter the month (1 ~ 12) ");
The scanf (" % d ", & amp; The month);
}
If (the month==4 | | the month 6==| | 9 month==| | the month==11)
Maxday=30;
Else if (the month==2)
{
//if (year %==0 400 | | year % 4==0)
If (year %==0 400 | | (year % 4==0 & amp; & Year % 100!=0))
Maxday=28;
The else
Maxday=29;
}
The else
Maxday=31;
Printf (" please enter the day of (1 ~ 31) ");
The scanf (" % d ", & amp; Day);
//if (day<1 | | day> Maxday)
While (day<1 | | day> Maxday)
{
Printf (" input error! Please input the new! \n");
Printf (" please enter the day of (1 ~ 31) ");
The scanf (" % d ", & amp; Day);
}
If (the month==maxmonth & amp; & Day==maxday)
{
Year=year + 1;
The month=1;
Day=1;
}
Else if (day==maxday)
{
The month=month + 1;
Day=1;
}
The else
Day=day + 1;
Printf (" the next day is on % d % d % d ", year, month, day);
getchar();
}
For your reference ~
CodePudding user response: