Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- namespace ConsoleApplication1
- {
- class Program
- {
- static void Main(string[] args)
- {
- Console.Write("Введите количество человек: ");
- int Persons = int.Parse(Console.ReadLine());
- Console.Write("Введите номер до какого мы будем считать: ");
- int number = int.Parse(Console.ReadLine());
- List<int> people = new List<int>();
- for (int i = 0; i < Persons; i++ )
- {
- people.Add(i + 1);
- }
- foreach (int i in people)
- Console.Write(i + " ");
- Console.WriteLine();
- //Сократить
- while (people.Count() > 1)
- {
- if (number > people.Count())
- number = number - people.Count();
- for (int i = 0; i < Persons; i++)
- {
- if ((i + 1) == number)
- {
- people.RemoveAt(i);
- i++;
- }
- }
- }
- foreach (int i in people)
- Console.Write(i + " ");
- Console.ReadKey();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement