Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.25 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3.  
  4. namespace ConsoleApp177
  5. {
  6.     class Program
  7.     {
  8.         static void Main(string[] args)
  9.         {
  10.             Dictionary<string, int> pointsPerPerson = new Dictionary<string, int>();
  11.             int numOfNewcomers = int.Parse(Console.ReadLine());
  12.             int sumName = 0;
  13.             int peopleInGf = 0;
  14.             int peopleInRev = 0;
  15.             int peopleInHuf = 0;
  16.             int peopleInSl = 0;
  17.  
  18.             for (int i = 0; i < numOfNewcomers; i++)
  19.             {
  20.                 string[] name = Console.ReadLine().Split(' ');
  21.                 string firstName = name[0];
  22.                 char firstInitial = firstName[0];
  23.                 string secondName = name[1];
  24.                 char secondInitial = secondName[0];
  25.                 string fullName = firstName + secondName;
  26.                 int fullNameLength = fullName.Length;
  27.  
  28.                 for (int j = 'a'; j <= 'z'; j++)
  29.                 {
  30.                     for (int k = 0; k < fullNameLength; k++)
  31.                     {
  32.                         if (fullName[k] == j)
  33.                         {
  34.                             sumName += j;
  35.                         }
  36.                     }
  37.                 }
  38.                 for (int m = 'A'; m <= 'Z'; m++)
  39.                 {
  40.                     if (firstInitial == m && secondInitial == m)
  41.                     {
  42.                         sumName += 2 * m;
  43.                     }
  44.                     else if (firstInitial == m || secondInitial == m)
  45.                     {
  46.                         sumName += m;
  47.                     }
  48.                 }
  49.  
  50.                 fullName = firstName + " " + secondName;
  51.                 pointsPerPerson.Add(fullName, sumName);
  52.                 sumName = 0;
  53.             }
  54.  
  55.  
  56.             foreach (var item in pointsPerPerson)
  57.             {
  58.                 string[] name = item.Key.Split(' ');
  59.                 string firstName = name[0];
  60.                 char firstInitial = firstName[0];
  61.                 string secondName = name[1];
  62.                 char secondInitial = secondName[0];
  63.                 if (item.Value % 4 == 0)
  64.                 {
  65.                     Console.WriteLine($"Gryffindor {item.Value}{firstInitial}{secondInitial}");
  66.                     peopleInGf++;
  67.                 }
  68.                 else if (item.Value % 4 == 1)
  69.                 {
  70.                     Console.WriteLine($"Slytherin {item.Value}{firstInitial}{secondInitial}");
  71.                     peopleInSl++;
  72.                 }
  73.                 else if (item.Value % 4 == 2)
  74.                 {
  75.                     Console.WriteLine($"Ravenclaw {item.Value}{firstInitial}{secondInitial}");
  76.                     peopleInRev++;
  77.                 }
  78.                 else if (item.Value % 4 == 3)
  79.                 {
  80.                     Console.WriteLine($"Hufflepuff {item.Value}{firstInitial}{secondInitial}");
  81.                     peopleInHuf++;
  82.                 }
  83.             }
  84.             Console.WriteLine();
  85.             Console.WriteLine($"Gryffindor: {peopleInGf}");
  86.             Console.WriteLine($"Slytherin: {peopleInSl}");
  87.             Console.WriteLine($"Ravenclaw: {peopleInRev}");
  88.             Console.WriteLine($"Hufflepuff: {peopleInHuf}");
  89.  
  90.         }
  91.     }
  92. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement