Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- int day, month, year;
- cout << "Vuvedi denq: ";
- cin >> day;
- cout << "Vuvedi month: ";
- cin >> month;
- cout << "Vuvedi year: ";
- cin >> year;
- if(month < 1 || month > 12)
- {
- cout << "Vuvedete pravilen mesec";
- return 0;
- }
- if(day < 1 || day > 31)
- {
- cout << "Vuvedi pravilen den";
- return 0;
- }
- else if(day > 29 && month == 2)
- {
- cout << "Vuvedi pravilen den";
- return 0;
- }
- else if(day == 29 && year % 400 != 0)
- {
- cout << "Vuvedi pravilen den";
- return 0;
- }
- if(day == 31 && (month == 4 || month == 6 || month == 9 || month == 11))
- {
- cout << "Vuvedi pravilen den";
- return 0;
- }
- int tomorrowYear = year;
- int tomorrowMonth = month;
- int tomorrowDay = day + 1;
- switch(tomorrowDay)
- {
- case 32:
- switch(tomorrowMonth)
- {
- case 1: case 3: case 5: case 7: case 8: case 10: case 12:
- tomorrowDay = 1;
- tomorrowMonth++;
- if(tomorrowMonth == 13)
- {
- tomorrowMonth = 1;
- tomorrowYear++;
- }
- break;
- }
- break;
- case 31:
- switch(tomorrowMonth)
- {
- case 4: case 6: case 9: case 11:
- tomorrowDay = 1;
- tomorrowMonth++;
- break;
- }
- break;
- case 30:
- if(tomorrowMonth == 2)
- {
- tomorrowDay = 1;
- tomorrowMonth = 3;
- }
- break;
- case 29:
- if (tomorrowMonth == 2)
- {
- if (tomorrowYear % 400 == 0)
- {
- }
- else
- {
- tomorrowDay = 1;
- tomorrowMonth = 3;
- }
- }
- break;
- }
- cout << "utre e: " << tomorrowDay << "/" << tomorrowMonth << "/" << tomorrowYear;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement