Advertisement
jtentor

Contando los domingos que fueron primeros de mes en el siglo

Sep 10th, 2014
320
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.64 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Verifica
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int sundaysFirstOfMonth = 0;
  10.  
  11.             for (int year = 1901; year <= 2000; ++year)
  12.             {
  13.                 for (int month = 1; month <= 12; ++month)
  14.                 {
  15.                     if ((new DateTime(year, month, 1)).DayOfWeek == DayOfWeek.Sunday)
  16.                     {
  17.                         ++sundaysFirstOfMonth;
  18.                     }
  19.                 }
  20.             }
  21.             Console.WriteLine("Ocurrieron {0} domingos que fueron primer día del mes", sundaysFirstOfMonth);
  22.         }
  23.     }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement