Advertisement
Arden

Untitled

May 9th, 2012
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.85 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. namespace C4USE2012
  7. {
  8.     class Program
  9.     {
  10.         static void Main(string[] args)
  11.         {
  12.             int value, l = 0, N;
  13.             int[,] count = new int[12, 1];
  14.             string[] words;
  15.             string[] months = { "января", "февраля", "марта", "апреля", "мая", "июня", "июля", "августа", "сентября", "октября", "ноября", "декабря" };
  16.             string[] factMonths = { "январь", "февраль", "март", "апрель", "май", "июнь", "июль", "август", "сентябрь", "октябрь", "ноябрь", "декабрь" };
  17.             string s;
  18.             char separator = ' ';
  19.             N = Convert.ToInt32(Console.ReadLine());
  20.             for (int i = 0; i < N; i++)
  21.             {
  22.                 s = Console.ReadLine();
  23.                 words = s.Split(separator);
  24.                   for (int k = 0; k < 12; k++)
  25.                     {
  26.                         foreach (string word in words)
  27.                         {
  28.                             if (word == months[k]) count[k, 0]++;
  29.                         }
  30.                     }
  31.             }
  32.             s = null;
  33.             words = null;
  34.             value = count[0, 0];
  35.             for (int i = 0; i < 12; i++)
  36.             {
  37.                 for (int j = 0; j < 12; j++)
  38.                 {
  39.                     if (count[j, 0] > value)
  40.                     {
  41.                         value = count[j, 0];
  42.                         l = j;
  43.                     }
  44.                 }
  45.                 if (value != 0) Console.WriteLine(factMonths[l] + ' ' + value);
  46.                 value = 0;
  47.                 count[l, 0] = 0;
  48.             }
  49.                 Console.ReadKey();
  50.         }
  51.     }
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement