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;

                    }            

                }

            }

        }

    }

  • 相关阅读:
    Python解析Yahoo的XML格式的天气预报数据
    如何卸载wineQQ?
    纪念我的第一篇
    hihocoder1062 最近公共祖先·一
    hihocoder1055 刷油漆(树形DP)
    hihocoder1050 树中的最长路径
    hihocoder1049 根据二叉树的先序序列和中序序列求后序序列
    hihocoder1044 状态压缩
    hihocoder1043 完全背包
    hihocoder1038 01背包
  • 原文地址:https://www.cnblogs.com/scudpurple/p/3370552.html
Copyright © 2011-2022 走看看