If you want to take the exam, write it. If you have the same requirements, take it away.
# Include <stdio. h>
Void main () // defines some date functions
{
Char tmps;
Do
{
Printf ("enter a date (year month day )");
Int year, month, day, tmp;
Scanf ("% d", & year, & month, & day );
If (year <1000 | year> 9999) // determines the year.
{
Printf ("the year is incorrect. Please enter a four-digit positive integer ");
}
Else if (month> 12 | month <1) // you can specify a month.
{
Printf ("incorrect monthly input, please enter a positive integer between 1 and 12 ");
}
Else
{
Switch (month) // defines the number of days per month
{
Case 1:
Tmp = 31;
Break;
Case 2:
Tmp = 28;
Break;
Case 3:
Tmp = 31;
Break;
Case 4:
Tmp = 30;
Break;
Case 5:
Tmp = 31;
Break;
Case 6:
Tmp = 30;
Break;
Case 7:
Tmp = 31;
Break;
Www.2cto.com
Case 8:
Tmp = 31;
Break;
Case 9:
Tmp = 30;
Break;
Case 10:
Tmp = 31;
Break;
Case 11:
Tmp = 30;
Break;
Case 12:
Tmp = 31;
Break;
}
If (day = tmp) // determines whether it is the last day
{
Printf ("the date of the next day is % d 1 \ n", year, month + 1 );
}
Else if (day = tmp & month = 12) // determines whether it is the last day of the last month.
{
Printf ("the date of the next day is % d 1 1 \ n", year + 1 );
}
Else
{
Printf ("the date of the next day is % d \ n", year, month, day + 1 );
}
}
Printf ("continue? (Y/n )");
Scanf ("% s", & tmps );
} While (tmps = 'y ');
}
From: Str1ven's Blog