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;

                }            

            }

        }

    }

}

posted @ 2013-10-15 17:01  云翔紫梦  阅读(3487)  评论(0编辑  收藏  举报