C# 有N个人围成一圈,第一个人从1开始报数,报到M的人出列,求依次出列的人的编号
C# with Array
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Query
{
class Program
{
static void Main(string[] args)
{
int[] query = new int [100];
for (int i =0; i<100; i++){query[i]=1;}
GetOut(query, 3);
Console.ReadLine();
}
static void GetOut(int[] arr, int standard)
{
int quiteNum = 0;
int index = -1;
int count = 0;
while (quiteNum < 100)
{
index++; if (index >= arr.Length) index = 0;
if (arr[index] == 1) count++;
if (count == 3)
{
arr[index] = 0;
quiteNum++;
Console.Write("index:" + index + ";");
count = 0;
}
}
}
}
}