Advertisement
aggressiveviking

05.DateAfter5Days

Mar 4th, 2020
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.79 KB | None | 0 0
  1. using System;
  2.  
  3. namespace _05.DateAfter5Days
  4. {
  5.     class DateAfter5Days
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int d = int.Parse(Console.ReadLine());
  10.             int m = int.Parse(Console.ReadLine());
  11.  
  12.             int daysInMonth = 31;
  13.  
  14.             if (m == 2)
  15.             {
  16.                 daysInMonth = 28;
  17.             }
  18.  
  19.             if (m == 4 || m == 6 || m == 9 || m == 11)
  20.             {
  21.                 daysInMonth = 30;
  22.             }
  23.  
  24.             d += 5;
  25.  
  26.             if (d > daysInMonth)
  27.             {
  28.                 d -= daysInMonth;
  29.                 m++;
  30.  
  31.                 if (m > 12)
  32.                 {
  33.                     m = 1;
  34.                 }
  35.             }
  36.  
  37.             Console.WriteLine($"{d}.{m:d2}");
  38.         }
  39.     }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement