aggressiveviking

06.NameGame

Feb 26th, 2020
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.13 KB | None | 0 0
  1. using System;
  2.  
  3. namespace _06.NameGame
  4. {
  5.     class NameGame
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             string name = Console.ReadLine();
  10.            
  11.             int bestPoints = 0;
  12.             string win = "";
  13.  
  14.             while (name != "Stop")
  15.             {
  16.                 int currentPoints = 0;
  17.                
  18.                 for (int i = 0; i < name.Length; i++)
  19.                 {
  20.                     int number = int.Parse(Console.ReadLine());
  21.                    
  22.                     if (number == name[i])
  23.                     {
  24.                         currentPoints += 10;
  25.                     }
  26.                     else
  27.                     {
  28.                         currentPoints += 2;
  29.                     }
  30.                 }
  31.  
  32.                 if (currentPoints >= bestPoints)
  33.                 {
  34.                     bestPoints = currentPoints;
  35.                     win = name;
  36.                 }
  37.                
  38.                 name = Console.ReadLine();
  39.             }
  40.            
  41.             Console.WriteLine($"The winner is {win} with {bestPoints} points!");
  42.         }
  43.     }
  44. }
Add Comment
Please, Sign In to add comment