天然灰

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

 

 

 

 static void Main(string[] args)
        {
              //输出1-100的素数
            bool res;
            int count = 0;
            for (int i = 1; i < 100; i++)
            {

                res = true;
                for (int j = 2; j < i; j++)
                {
                    count++;
                    res = i % j == 0 ? res = false : res = true;  
                    break;                       
                }
                if (res)
                {
                    Console.WriteLine(i);
                }
            
            }
            Console.WriteLine("循环了" + count);
            Console.ReadKey();
        }

 

posted on 2018-12-14 12:12  天然灰  阅读(421)  评论(0编辑  收藏  举报