用C#编程:求出2~100之间的所有素数,要求每行打印6个

来源:百度知道 编辑:UC知道 时间:2024/05/11 12:48:16
万分火急!!

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

namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int connt=0;
for (int x = 2; x < 100; x++)
{
for (int y = 2; y <x; y++)
{
if (x % y == 0)
{
goto abcd;
}
}
Console.Write("{0,9}", x);
connt++;
if (connt >= 6)
{
Console.WriteLine();
connt = 0;
}
abcd: ;
}
}
}
}