Advertisement
Pafnytiu

Untitled

Sep 4th, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.34 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. namespace ConsoleApplication1
  7. {
  8. class Program
  9. {
  10. static void Main(string[] args)
  11. {
  12. Console.Write("Введите количество человек: ");
  13. int Persons = int.Parse(Console.ReadLine());
  14. Console.Write("Введите номер до какого мы будем считать: ");
  15. int number = int.Parse(Console.ReadLine());
  16. List<int> people = new List<int>();
  17. for (int i = 0; i < Persons; i++ )
  18. {
  19. people.Add(i + 1);
  20. }
  21. foreach (int i in people)
  22. Console.Write(i + " ");
  23. Console.WriteLine();
  24. //Сократить
  25. while (people.Count() > 1)
  26. {
  27. if (number > people.Count())
  28. number = number - people.Count();
  29. for (int i = 0; i < Persons; i++)
  30. {
  31. if ((i + 1) == number)
  32. {
  33. people.RemoveAt(i);
  34. i++;
  35. }
  36. }
  37. }
  38. foreach (int i in people)
  39. Console.Write(i + " ");
  40. Console.ReadKey();
  41. }
  42. }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement