Advertisement
abasar

Date.cs

Feb 14th, 2016
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.03 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace ConsoleApplication1
  8. {
  9.     class Date
  10.     {
  11.         private int day;
  12.         private int month;
  13.         private int year;
  14.         public Date(int day, int month, int year)
  15.         {
  16.             this.day = day;
  17.             this.month = month;
  18.             this.year = year;
  19.         }
  20.         public int GetYear()
  21.         {
  22.             return this.year;
  23.         }
  24.         public int GetMonth()
  25.         {
  26.             return this.month;
  27.         }
  28.         public int GetDay()
  29.         {
  30.             return this.day;
  31.         }
  32.         public int DaysInYear()
  33.         {
  34.             if (this.year % 4 == 0)
  35.                 return 366;
  36.             else
  37.                 return 365;
  38.         }
  39.         public bool IsInteresting()
  40.         {
  41.             bool ans;
  42.             bool oneDigit = this.day / 10 == 0;
  43.             if (oneDigit)
  44.                 ans = this.day == this.year % 10;
  45.             else
  46.                 ans = this.day == this.year % 100;
  47.             return this.day == this.month && ans == true;
  48.         }
  49.         public int DaysPass()
  50.         {
  51.             int num = (this.month - 1) * 31 + this.day;
  52.             if (this.month > 2)
  53.             {
  54.                 num = num - 2;
  55.                 if (this.year % 4 != 0)
  56.                     num = num - 1;
  57.             }
  58.             if (this.month > 4) num = num - 1;
  59.             if (this.month > 6) num = num - 1;
  60.             if (this.month > 9) num = num - 1;
  61.             if (this.month > 11) num = num - 1;
  62.             return num;
  63.         }
  64.         public string ToString()
  65.         {
  66.             return this.day + "/" + this.month + "/" + this.year;
  67.         }
  68.     }
  69. }
  70.  
  71. -----------------------------------------------------------
  72. //#7
  73. using System;
  74. using System.Collections.Generic;
  75. using System.Linq;
  76. using System.Text;
  77. using System.Threading.Tasks;
  78.  
  79. namespace ConsoleApplication1
  80. {
  81.     class Program
  82.     {
  83.         static void Main(string[] args)
  84.         {
  85.             int j = 0;
  86.             for (int i = 0; i < 20; i++)
  87.             {
  88.                 Date d1 = new Date(int.Parse(Console.ReadLine()), int.Parse(Console.ReadLine()), int.Parse(Console.ReadLine()));
  89.                 if (d1.IsInteresting())
  90.                     j++;
  91.             }
  92.             Console.WriteLine(j);
  93.         }
  94.     }
  95. }
  96. --------------------------------------------------------------
  97. //#8
  98. using System;
  99. using System.Collections.Generic;
  100. using System.Linq;
  101. using System.Text;
  102. using System.Threading.Tasks;
  103.  
  104. namespace ConsoleApplication1
  105. {
  106.     class Program
  107.     {
  108.         static void Main(string[] args)
  109.         {
  110.             int daysSum = 0;
  111.             while (daysSum < 400)
  112.             {
  113.                 Date d1 = new Date(int.Parse(Console.ReadLine()), int.Parse(Console.ReadLine()), int.Parse(Console.ReadLine()));
  114.                 daysSum += d1.DaysPass();
  115.             }
  116.             Console.WriteLine(daysSum);
  117.         }
  118.     }
  119. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement