BSO90

Проблем със задача 6 от изпита PB от 6-7 юли 2019

May 12th, 2020
388
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.55 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 GameOfNames
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             string input = Console.ReadLine();
  14.             int MaxPoints = int.MinValue;
  15.             string firstPlayername = "";
  16.             string secondPlayername = "";
  17.             int pointsFirstplayer = 0;
  18.             int pointsSecondplayer = 0;
  19.             while (input != "Stop")
  20.             {
  21.                 for (int i = 0; i < input.Length; i++)
  22.                 {
  23.                     int num = int.Parse(Console.ReadLine());
  24.                     if (num == input[i])
  25.                     {
  26.                         pointsFirstplayer += 10;
  27.                     }
  28.                     else
  29.                     {
  30.                         pointsFirstplayer += 2;
  31.                     }
  32.                 }
  33.                 if (pointsFirstplayer >= MaxPoints)
  34.                 {
  35.                     MaxPoints = pointsFirstplayer;
  36.                     firstPlayername = input;
  37.                 }
  38.                 input = Console.ReadLine();
  39.                 if (input == "Stop")
  40.                 {
  41.                     break;
  42.                 }
  43.                 for (int i = 0; i < input.Length; i++)
  44.                 {
  45.                     int num = int.Parse(Console.ReadLine());
  46.                     if (num == input[i])
  47.                     {
  48.                         pointsSecondplayer += 10;
  49.                     }
  50.                     else
  51.                     {
  52.                         pointsSecondplayer += 2;
  53.                     }
  54.                     secondPlayername = input;
  55.  
  56.                     if (input == "Stop")
  57.                     {
  58.                         break;
  59.                     }
  60.                 }
  61.                 input = Console.ReadLine();
  62.             }
  63.                
  64.                 if (pointsFirstplayer > pointsSecondplayer)
  65.                 {
  66.                     Console.WriteLine($"The winner is {firstPlayername} with {pointsFirstplayer} points!");
  67.                 }
  68.                 else if (pointsFirstplayer < pointsSecondplayer)
  69.                 {
  70.                     Console.WriteLine($"The winner is {secondPlayername} with {pointsSecondplayer} points!");
  71.                 }
  72.                 else if (pointsFirstplayer == pointsSecondplayer)
  73.                 {
  74.                     Console.WriteLine($"The winner is {secondPlayername} with {pointsSecondplayer} points!");
  75.                 }
  76.         }
  77.     }
  78. }
Add Comment
Please, Sign In to add comment