SHARE
TWEET

sum of days

Aliendreamer Jul 10th, 2018 83 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top