using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace _2_1
{
class Program
{
static void Main(string[] args)
{
/*===================================
* 工程:经典算法实现
* 题目:判断101-200之间有多少个素数,并输出所有素数
* 作者:王剑
* 版本:1.0
* 日期:2011-09-23
=====================================*/
int i, k, m, h = 0;
bool leap=true;
for (m = 101; m <= 200; m++)
{
k = (int)(Math.Sqrt(m + 1));
for (i = 2; i <= k; i++)
{
if (m % i == 0)
{
leap=!leap;
break;
}
if (leap)
{
Console.Write("{0} ", m);
h++;
if (h % 8 == 0)
{
Console.Write("\n");
}
leap = !leap;
}
}
}
Console.WriteLine("\n素数的个数为{0}", h);
Console.ReadKey();
}
}
}
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace _2_1
{
class Program
{
static void Main(string[] args)
{
/*===================================
* 工程:经典算法实现
* 题目:判断101-200之间有多少个素数,并输出所有素数
* 作者:王剑
* 版本:1.0
* 日期:2011-09-23
=====================================*/
int i, k, m, h = 0;
bool leap=true;
for (m = 101; m <= 200; m++)
{
k = (int)(Math.Sqrt(m + 1));
for (i = 2; i <= k; i++)
{
if (m % i == 0)
{
leap=!leap;
break;
}
if (leap)
{
Console.Write("{0} ", m);
h++;
if (h % 8 == 0)
{
Console.Write("\n");
}
leap = !leap;
}
}
}
Console.WriteLine("\n素数的个数为{0}", h);
Console.ReadKey();
}
}
}