Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- using System.Collections.Generic;
- class Player
- {
- public static Dictionary<int, string> MyDic(int n)
- {
- Dictionary<int, string> dic = new Dictionary<int, string>();
- Console.WriteLine("Введите имя : \n");
- string s;
- for (int j = 1; j <= n; j++)
- {
- Console.Write("Имя{0} --> ", j);
- s = Console.ReadLine();
- dic.Add(j, s);
- }
- return dic;
- }
- }
- class Program
- {
- public static void Main()
- {
- Console.Write("Сколько игроков добавить?");
- int n = int.Parse(Console.ReadLine());
- Dictionary<int, string> dic = Player.MyDic(n);
- Console.Write("До какого считать?");
- int k = int.Parse(Console.ReadLine());
- ICollection<int> keys = dic.Keys;
- while (keys.Count != 1)
- {
- for (int i = 1; i <= k; ++i)
- {
- if(i == k)
- {
- dic.Remove(i);//тут проблема :/
- }
- }
- }
- foreach (int i in keys)
- {
- Console.Write("Остался:" + dic[i]);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment