#include<stdio.h> void NextTime(int day, int month, int year) { // count day and month day = day + 1; printf("Next time: "); if(month == 1 || month == 3 || month == 5 || month == 7 || month == 9 || month == 11) { if(day > 31 && month < 12) { printf("1/%d/", month + 1); } else if(day <= 31 && month < 12) { printf("%d/%d/",day ,month); } } else if(month == 4 || month == 6 || month == 8 || month == 10 || month == 12) { if(day > 30 && month == 12) { printf("1/1/"); } else if(day > 30 && month < 12) { printf("1/%d/", month + 1); } else if(day <= 30 && month <= 12) { printf("%d/%d/", day, month); } } else if(month == 2) { if(day > 28) { printf("1/3/"); } else if(day <= 28) { printf("%d/2/", day); } } //count year if( day > 30 && month == 12) { printf("%d", year + 1); } else if(day <= 31 && month < 12 || day > 31 && month < 12 ) { printf("%d", year); } } void main() { int day, month, year; //check input data do { do { printf("enter day: "); scanf("%d", &day); if(day > 31 || day <= 0) { printf(">>ERROR! day <= 30\n"); } }while(day > 31 || day <= 0); do { printf("enter month: "); scanf("%d", &month); if(month > 12 || month < 1) { printf(">>ERROR! month >= 12\n"); } }while(month > 12 || month < 1); if(month == 2 && day > 28 || month == 4 && day > 30 || month == 6 && day > 30 || month == 8 && day > 30 || month == 10 && day > 30 || month == 12 && day > 30) { printf(">>ERROR! day of month\n"); printf("month [2] : 28 day\n"); printf("month [4] [6] [8] [10] [12] : 30 day\n"); printf("month [1] [3] [5] [7] [9] [11] : 31 day\n\n"); } }while(month == 2 && day > 28 || month == 4 && day > 30 || month == 6 && day > 30 || month == 8 && day > 30 || month == 10 && day > 30 || month == 12 && day > 30); do { printf("enter year: "); scanf("%d", &year); if(year < 2000) { printf(">>ERROR! year >= 2000"); } }while(year < 2000); NextTime(day, month, year); }