圈人数数:An interesting way to delete numbers

来源:互联网 发布:网络语吃糠是什么意思 编辑:程序博客网 时间:2024/04/30 21:57

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace choice
{
    class Program
    {
        static void Main(string[] args)
        {
            int count=0;
            int sum = 0;
            int[] sort = new int[10];
            for (int i = 0; i < 10; i++)
            {
                sort[i] = i + 1;
            }
                for (int j = 0; j < 10&&sum<9; j++)
                {
                    if (sort[j] != 0)
                    {
                        Console.WriteLine(sort[j]);
                        count = (count + 1) % 3;
                        if (count == 0)
                        {
                            sort[j] = 0;
                            sum+=1;
                        }
                    }
                    if (j == 9)
                    {
                        j =-1;
                       
                    }

                }
            for (int n = 0; n < 10; n++)
            {
                if (sort[n] != 0)
                    Console.Write(sort[n]);
                Console.WriteLine();
            }
            Console.ReadKey();
        }
    }
}