Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Globalization;
- namespace _01.CountWorkingDaYS
- {
- class Program
- {
- static void Main(string[] args)
- {
- string startDateStr = Console.ReadLine();
- string endDateStr = Console.ReadLine();
- DateTime startDate = DateTime.ParseExact(startDateStr, "dd-MM-yyyy",CultureInfo.InvariantCulture);
- DateTime endDate = DateTime.ParseExact(endDateStr, "dd-MM-yyyy", CultureInfo.InvariantCulture);
- DateTime[] nonWorking = new DateTime[] //[11] //{DateTime.ParseExact("") };
- {
- new DateTime(4,01,01), //пълня масив с неработните празници
- new DateTime(4,03,03),
- new DateTime(4,05,01),
- new DateTime(4,05,06),
- new DateTime(4,05,24),
- new DateTime(4,09,06),
- new DateTime(4,09,22),
- new DateTime(4,11,01),
- new DateTime(4,12,24),
- new DateTime(4,12,25),
- new DateTime(4,12,26)
- };
- int countWorkDays = 0;
- for (DateTime i = startDate; i <= endDate; i=i.AddDays(1))
- {
- if (!(i.DayOfWeek == DayOfWeek.Saturday) && !(i.DayOfWeek == DayOfWeek.Sunday))
- {
- countWorkDays++;
- foreach (var item in nonWorking)
- {
- if ((i.Day == item.Day) && (i.Month == item.Month))
- {
- countWorkDays--;
- }
- }
- }
- }
- Console.WriteLine(countWorkDays);
- /*for (int i = 0; i < nonWorking.Length; i++)
- {
- }*/
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement