zoukankan      html  css  js  c++  java
  • 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;

                    }            

                }

            }

        }

    }

  • 相关阅读:
    Oslec Echo Canceller:开源回声消除方案
    引用:SpeechLinks
    打印论文分类
    语音算法方案公司
    推送 push
    Android完美多语言应用,不重启应用,不改变系统语言
    定时任务quartz
    在android平台解决找不到sun.misc.BASE64Enocder的问题
    IOS背景view隐藏键盘
    为ExpandableListView自定义Item
  • 原文地址:https://www.cnblogs.com/scudpurple/p/3370552.html
Copyright © 2011-2022 走看看