Advertisement
Norvager

ДР

Nov 28th, 2018
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.51 KB | None | 0 0
  1. #define _CRT_SECURE_NO_WARNINGS
  2. #include <cstdio>
  3. #include <vector>
  4. using namespace std;
  5.  
  6. int day1(int days, int m_1, int m_2, int d_1, int d_2, int k)
  7. {
  8.     for (int i = 1; i <= m_2; i++)
  9.     {
  10.         if (i == 2)
  11.         {
  12.             days -= k;
  13.         }
  14.         else if ((i <= 7 && i % 2 != 0) || (i > 7 && i % 2 == 0))
  15.         {
  16.             days -= 31;
  17.         }
  18.         else days -= 30;
  19.     }
  20.  
  21.     if (m_2 != 2)
  22.     {
  23.         if ((m_2 <= 7 && m_2 % 2 != 0) || (m_2 > 7 && m_2 % 2 == 0))
  24.         {
  25.             days += 31 - d_2;
  26.         }
  27.         else days += 30 - d_2;
  28.     }
  29.     else days += k - d_2;
  30.  
  31.     for (int i = m_1; i <= 12; i++)
  32.     {
  33.         if (i == 2)
  34.         {
  35.             days -= k;
  36.         }
  37.         else if ((i <= 7 && i % 2 != 0) || (i > 7 && i % 2 == 0))
  38.         {
  39.             days -= 31;
  40.         }
  41.         else days -= 30;
  42.     }
  43.     days += d_1;
  44.    
  45.     return days;
  46. }
  47.  
  48. int day2(int days, int m_1, int m_2, int d_1, int d_2, int k)
  49. {
  50.  
  51. }
  52.  
  53. int main()
  54. {
  55. #ifndef ONLINE_JUDGE
  56.     freopen("input.txt", "r", stdin);
  57.     freopen("output.txt", "w", stdout);
  58. #endif // !ONLINE_JUDGE
  59.     int year_cur;
  60.     int d_birth, m_birth, d_cur, m_cur, days;
  61.     scanf("%d %d %d %d %d", &d_birth, &m_birth, &d_cur, &m_cur, &year_cur);
  62.     if (m_birth > m_cur)
  63.     {
  64.         if ((year_cur % 400 == 0) || (year_cur % 4 == 0 && year_cur % 100 != 0))
  65.         {
  66.             days = day1(366, m_birth, m_cur, d_birth, d_cur, 29);
  67.         }
  68.         else
  69.         {
  70.             days = day1(365, m_birth, m_cur, d_birth, d_cur, 28);
  71.         }
  72.     }
  73.     else if (m_birth < m_cur)
  74.     {
  75.         if (((year_cur + 1) % 400 == 0) || ((year_cur + 1) % 4 == 0 && (1 + year_cur) % 100 != 0))
  76.         {
  77.            
  78.         }
  79.         else
  80.         {
  81.            
  82.         }
  83.     }
  84.     printf("%d", days);
  85.     return 0;
  86. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement