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;

                    }            

                }

            }

        }

    }

  • 相关阅读:
    问世即屠榜的bert
    写给日后面试的小朋友们~
    SQL笔记续补
    《姜子牙》视频笔记
    知识图谱之小米的落地与应用探索
    Pyspark ml
    一个小时学会用 Go 编写命令行工具
    C#设计模式-组合模式(Composite Pattern)
    C#设计模式-桥接模式(Bridge Pattern)
    C#设计模式-装饰器模式(Decorator Pattern)
  • 原文地址:https://www.cnblogs.com/scudpurple/p/3370552.html
Copyright © 2011-2022 走看看