Bob103

C#_XmlSecondSolution

Sep 5th, 2017
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.25 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. using System.Collections.Generic;
  4.  
  5. class Player
  6. {
  7.     public static Dictionary<int, string> MyDic(int n)
  8.     {
  9.         Dictionary<int, string> dic = new Dictionary<int, string>();
  10.         Console.WriteLine("Введите имя : \n");
  11.         string s;
  12.         for (int j = 1; j <= n; j++)
  13.         {
  14.             Console.Write("Имя{0} --> ", j);
  15.             s = Console.ReadLine();
  16.             dic.Add(j, s);
  17.         }
  18.         return dic;
  19.     }
  20. }
  21.  
  22.  
  23. class Program
  24. {
  25.     public static void Main()
  26.     {
  27.         Console.Write("Сколько игроков добавить?");
  28.         int n = int.Parse(Console.ReadLine());
  29.         Dictionary<int, string> dic = Player.MyDic(n);
  30.         Console.Write("До какого считать?");
  31.         int k = int.Parse(Console.ReadLine());
  32.  
  33.         ICollection<int> keys = dic.Keys;
  34.         while (keys.Count != 1)
  35.          {
  36.            for (int i = 1; i <= k; ++i)
  37.             {
  38.               if(i == k)
  39.                 {
  40.                     dic.Remove(i);//тут проблема :/
  41.                 }
  42.             }
  43.          }
  44.         foreach (int i in keys)
  45.         {
  46.             Console.Write("Остался:" + dic[i]);
  47.         }
  48.      }
  49. }
Advertisement
Add Comment
Please, Sign In to add comment