Advertisement
Valantina

NameGame/Exam

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