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 阅读( ...) 评论( ...)