100以内质数每行5个
2016-08-07 21:29
405 查看
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace _100以内的质数_一行5个
{
class Program
{
static void Main(string[] args)
{
int k=0;
for (int a = 2; a <= 100; a++)
{
if (a == 2 || a == 3 || a == 5 || a == 7)
{
Console.Write("{0}{1}", a, ++k % 5 != 0 ? " " : "\r\n");
}
else if ((a % 2 == 0 || a % 3 == 0 || a % 5 == 0 || a % 7 == 0) && (a != 2 || a != 3 || a != 5 || a != 7))
{
continue;
}
else
{
Console.Write("{0}{1}", a , ++k % 5 != 0 ? " " : "\r\n");
}
}Console.ReadKey();
}
}
}
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace _100以内的质数_一行5个
{
class Program
{
static void Main(string[] args)
{
int k=0;
for (int a = 2; a <= 100; a++)
{
if (a == 2 || a == 3 || a == 5 || a == 7)
{
Console.Write("{0}{1}", a, ++k % 5 != 0 ? " " : "\r\n");
}
else if ((a % 2 == 0 || a % 3 == 0 || a % 5 == 0 || a % 7 == 0) && (a != 2 || a != 3 || a != 5 || a != 7))
{
continue;
}
else
{
Console.Write("{0}{1}", a , ++k % 5 != 0 ? " " : "\r\n");
}
}Console.ReadKey();
}
}
}
相关文章推荐
- 打印出100以内的质数,一行显示5个
- 求100以内的质数
- C语言打印100以内的质数
- 输出100以内的所有质数--九九乘法表--作业
- [sql server] 查出100以内的素数(质数)
- 输出100以内的所有质数--九九乘法表--作业
- python输出100以内的质数与合数实例代码
- 列出100以内的素数(质数)
- 100以内质数
- 找出100以内的质数并求和
- 列出100以内的质数
- 计算1到100以内前5个能被3整除的数字
- python实现挑选出来100以内的质数
- 求100以内的质数
- 编写一个找出100以内质数的程序
- 输出100以内的质数
- 输出100以内质数
- 求100以内的质数
- python实现100以内的质数和非质数
- 计算100以内的质数或合数