Advertisement
Aliendreamer

sum of days

Jul 10th, 2018
248
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.01 KB | None | 0 0
  1. namespace ConsoleApp1
  2. {
  3.     using System;
  4.     using System.Globalization;
  5.  
  6.     class Program
  7.     {
  8.         static void Main(string[] args)
  9.         {
  10.             string format = "dd-MM-yyyy";
  11.             int counter1 = 0;
  12.             int counter2 = 0;
  13.             //we read the input here
  14.             int n = int.Parse(Console.ReadLine());            
  15.             DateTime date1=DateTime.ParseExact(Console.ReadLine(),format,CultureInfo.InvariantCulture);
  16.             DateTime date2 = DateTime.ParseExact(Console.ReadLine(), format, CultureInfo.InvariantCulture);
  17.  
  18.             for (int i = 1; i <= n; i++)
  19.             {
  20.                 if (i % 2 == 0)
  21.                 {
  22.                     counter1++;
  23.                 }
  24.                 else
  25.                 {
  26.                     counter2++;
  27.                 }
  28.             }
  29.  
  30.            int one = date1.AddDays(counter1).Day;
  31.            int two = date2.AddDays(counter2).Day;
  32.  
  33.            
  34.             Console.WriteLine(one+two);
  35.         }
  36.     }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement