fbinnzhivko

02.00 Hogwarts Sorting

Apr 21st, 2016
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.57 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3.  
  4. class Program
  5. {
  6.     static void Main()
  7.     {
  8.         //Gryffindor (if reminder = 0),
  9.         //Slytherin(if 1),
  10.         //Ravenclaw(if 2)
  11.         //Hufflepuff (if 3).
  12.  
  13.         int n = int.Parse(Console.ReadLine());
  14.  
  15.         int counterG = 0;
  16.         int counterS = 0;
  17.         int counterR = 0;
  18.         int counterH = 0;
  19.  
  20.         for (int i = 0; i < n; i++)
  21.         {
  22.             string inputs = Console.ReadLine();
  23.  
  24.             string first = inputs.Substring(0, 1);
  25.             string[] dad = inputs.Split();
  26.  
  27.             string secound = dad[1].Substring(0, 1);
  28.            
  29.             var sum = inputs.Select(p => Convert.ToInt32(p)).Sum() - 32;
  30.  
  31.             var ostatak = sum % 4;
  32.             if (ostatak == 0)
  33.             {
  34.                 Console.WriteLine("Gryffindor {0}{1}{2}", sum, first, secound);
  35.                 counterG++;
  36.             }
  37.             if (ostatak == 1)
  38.             {
  39.                 Console.WriteLine("Slytherin {0}{1}{2}", sum, first, secound);
  40.                 counterS++;
  41.             }
  42.             if (ostatak == 2)
  43.             {
  44.                 Console.WriteLine("Ravenclaw {0}{1}{2}", sum, first, secound);
  45.                 counterR++;
  46.             }
  47.             if (ostatak == 3)
  48.             {
  49.                 Console.WriteLine("Hufflepuff {0}{1}{2}", sum, first, secound);
  50.                 counterH++;
  51.             }
  52.  
  53.         }
  54.         Console.WriteLine("\nGryffindor: {0}\nSlytherin: {1}\nRavenclaw: {2}\nHufflepuff: {3}",
  55.             counterG, counterS, counterR, counterH);
  56.     }
  57. }
Add Comment
Please, Sign In to add comment