Advertisement
kokokozhina

v1_4_1

Dec 15th, 2015
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.80 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. struct date
  6. {
  7.     int day, month, year;
  8. };
  9.  
  10. bool vis(int year)
  11. {
  12.     if ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0)
  13.         return true;
  14.     else
  15.         return false;
  16. }
  17.  
  18. int whatday(int month, int year)
  19. {
  20.     if (month == 3)
  21.         {
  22.             if (vis(year) == true)
  23.                 return 29;
  24.             else
  25.                 return 28;
  26.         }
  27.     else
  28.         {
  29.             if (month == 8 || (month < 8 && month % 2 == 0) || (month > 8 && month % 2 != 0))
  30.                 return 31;
  31.             else
  32.                 return 30;
  33.         }  
  34. }
  35.  
  36. int main()
  37. {
  38.     date a;
  39.     cin >> a.day >> a.month >> a.year;
  40.     if (a.day > 1)
  41.         cout << a.day - 1 << "." << a.month << "." << a.year;
  42.     else
  43.     {
  44.         if (a.month > 1)
  45.             cout << whatday(a.month, a.year) << "." << a.month - 1 << "." << a.year;
  46.         else
  47.             cout << "31.12." << a.year - 1;
  48.     }
  49.  
  50.     return 0;
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement