Advertisement
braveheart1989

Hogwarts

Apr 16th, 2016
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.19 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.  
  7. namespace _05.Task5
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             long n = long.Parse(Console.ReadLine());
  14.             string sum = string.Empty;
  15.             List<string> names = new List<string>();
  16.             string housesGR = "Gryffindor";
  17.             string housesSl = "Slytherin ";
  18.             string housesRaven = "Ravenclaw ";
  19.             string housesHuff = "Hufflepuff ";
  20.             string sum1 = string.Empty;
  21.             int Gryffindor = 0;
  22.             int Slytherin = 0;
  23.             int Ravenclaw = 0;
  24.             int Hufflepuff = 0;
  25.  
  26.             for (int i = 0; i < n; i++)
  27.             {
  28.                 string[] input = Console.ReadLine().Split(' ').ToArray();
  29.                 string initi = "" + input[0][0] + input[1][0];
  30.                 sum = SumStudentsName(sum, input);
  31.                 sum1 = sum;
  32.                 //sum = sum.Substring(0, sum.Length - 2);
  33.                 if (long.Parse(sum) % 4 == 0)
  34.                 {
  35.                     names.Add(housesGR.ToString() + " ");
  36.                     names.Add(sum1.ToString()+initi + "\n");
  37.                     sum = string.Empty;
  38.                     Gryffindor++;
  39.                 }
  40.                 else if (int.Parse(sum) % 4 == 1)
  41.                 {
  42.                     names.Add(housesSl);
  43.                     names.Add(sum1.ToString() + initi + "\n");
  44.                     sum = string.Empty;
  45.                     Slytherin++;
  46.                 }
  47.                 else if (long.Parse(sum) % 4 == 2)
  48.                 {
  49.                     names.Add(housesRaven);
  50.                     names.Add(sum1.ToString() + initi + "\n");
  51.                     sum = string.Empty;
  52.                     Ravenclaw++;
  53.                 }
  54.                 else if (long.Parse(sum) % 4 == 3)
  55.                 {
  56.                     names.Add(housesHuff);
  57.                     names.Add(sum1.ToString() + initi + "\n");
  58.                     sum = string.Empty;
  59.                     Hufflepuff++;
  60.                 }
  61.             }
  62.             Console.WriteLine(string.Join("", names));
  63.             Console.WriteLine("Gryffindor: {0}", Gryffindor);
  64.             Console.WriteLine("Slytherin: {0}", Slytherin);
  65.             Console.WriteLine("Ravenclaw: {0}", Ravenclaw);
  66.             Console.WriteLine("Hufflepuff: {0}", Hufflepuff);
  67.  
  68.         }
  69.         private static string SumStudentsName(string sum, string[] input)
  70.         {
  71.             long sum1 = 0;
  72.             long sum2 = 0;
  73.             string capitalLetter = string.Empty;
  74.             foreach (var item in input[0])
  75.             {
  76.                 sum1 += item;
  77.                 //if (char.IsUpper(item))
  78.                 //{
  79.                 //    capitalLetter += item;
  80.                 //}
  81.             }
  82.             foreach (var item in input[1])
  83.             {
  84.                 sum2 += item;
  85.                 //if (char.IsUpper(item))
  86.                 //{
  87.                 //    capitalLetter += item;
  88.                 //}
  89.             }
  90.  
  91.             sum = ((sum1 + sum2).ToString());
  92.             return sum.ToString();
  93.         }
  94.     }
  95. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement