Advertisement
Ronka

Untitled

Jun 21st, 2017
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.65 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. using System.Globalization;
  7.  
  8. namespace ConsoleApp1
  9. {
  10. class Program
  11. {
  12. static void Main(string[] args)
  13. {
  14. string start = Console.ReadLine();
  15. string end = Console.ReadLine();
  16.  
  17. DateTime startDate = DateTime.ParseExact(start, "dd-MM-yyyy", CultureInfo.InvariantCulture);
  18. DateTime endDate = DateTime.ParseExact(end, "dd-MM-yyyy",CultureInfo.InvariantCulture);
  19.  
  20. DateTime[] holidays = new DateTime[12];
  21.  
  22. holidays[0] = new DateTime(4,01,01);
  23. holidays[1] = new DateTime(4, 03, 03);
  24. holidays[2] = new DateTime(4, 05, 01);
  25. holidays[3] = new DateTime(4, 05, 06);
  26. holidays[4] = new DateTime(4, 05, 24);
  27. holidays[5] = new DateTime(4, 09, 06);
  28. holidays[6] = new DateTime(4, 09, 22);
  29. holidays[7] = new DateTime(4, 11, 01);
  30. holidays[9] = new DateTime(4, 12, 24);
  31. holidays[10] = new DateTime(4, 12, 25);
  32. holidays[11] = new DateTime(4, 12, 26);
  33.  
  34. int counter = 0;
  35.  
  36. for (DateTime i = startDate; i <= endDate; i = i.AddDays(1))
  37. {
  38. DayOfWeek day = i.DayOfWeek;
  39.  
  40. DateTime temp = new DateTime(4, i.Month, i.Day);
  41.  
  42. if (!holidays.Contains(temp) && !day.Equals(DayOfWeek.Saturday) && !day.Equals(DayOfWeek.Sunday))
  43. {
  44. counter++;
  45. }
  46. }
  47.  
  48. Console.WriteLine(counter);
  49.  
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement