• 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;

                    }            

                }

            }

        }

    }

  • 相关阅读:
    javascript面向对象(三)--继承
    javascript面向对象(一)
    jsp/servlet学习笔记(核心编程)mysql部分
    jsp/servlet学习笔记(核心编程)servlet部分
    没有为扩展名“.html”注册的生成提供程序
    vs2012 mvc3项目ObjectContext与DBContext(转载)
    反射与动态代理
    spring-ioc

    哈希表
  • 原文地址:https://www.cnblogs.com/scudpurple/p/3370552.html
Copyright © 2020-2023  润新知