您的位置:首页 > 编程语言 > C#

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();

        }

    }

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  c# 质数