Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ConsoleApplication1
- {
- class Date
- {
- private int day;
- private int month;
- private int year;
- public Date(int day, int month, int year)
- {
- this.day = day;
- this.month = month;
- this.year = year;
- }
- public int GetYear()
- {
- return this.year;
- }
- public int GetMonth()
- {
- return this.month;
- }
- public int GetDay()
- {
- return this.day;
- }
- public int DaysInYear()
- {
- if (this.year % 4 == 0)
- return 366;
- else
- return 365;
- }
- public bool IsInteresting()
- {
- bool ans;
- bool oneDigit = this.day / 10 == 0;
- if (oneDigit)
- ans = this.day == this.year % 10;
- else
- ans = this.day == this.year % 100;
- return this.day == this.month && ans == true;
- }
- public int DaysPass()
- {
- int num = (this.month - 1) * 31 + this.day;
- if (this.month > 2)
- {
- num = num - 2;
- if (this.year % 4 != 0)
- num = num - 1;
- }
- if (this.month > 4) num = num - 1;
- if (this.month > 6) num = num - 1;
- if (this.month > 9) num = num - 1;
- if (this.month > 11) num = num - 1;
- return num;
- }
- public string ToString()
- {
- return this.day + "/" + this.month + "/" + this.year;
- }
- }
- }
- -----------------------------------------------------------
- //#7
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ConsoleApplication1
- {
- class Program
- {
- static void Main(string[] args)
- {
- int j = 0;
- for (int i = 0; i < 20; i++)
- {
- Date d1 = new Date(int.Parse(Console.ReadLine()), int.Parse(Console.ReadLine()), int.Parse(Console.ReadLine()));
- if (d1.IsInteresting())
- j++;
- }
- Console.WriteLine(j);
- }
- }
- }
- --------------------------------------------------------------
- //#8
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ConsoleApplication1
- {
- class Program
- {
- static void Main(string[] args)
- {
- int daysSum = 0;
- while (daysSum < 400)
- {
- Date d1 = new Date(int.Parse(Console.ReadLine()), int.Parse(Console.ReadLine()), int.Parse(Console.ReadLine()));
- daysSum += d1.DaysPass();
- }
- Console.WriteLine(daysSum);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement