【C#课堂练习】输出1-100的素数
本文最后更新于 1549 天前,其中的信息可能已经有所发展或是发生改变。

Class2.cs

[sourcecode language=”c” title=”Class2.cs”]
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
class Class2
{
static void Main(string[] args)
{
Console.WriteLine("整数1不是素数!");
for (int m = 2; m<= 100; m++) {
bool flag = true;
int k = (int)(Math.Sqrt(m));
int i = 2;
while (i <= k && flag == true)
{
if (m % i == 0) flag = false;
else i++;
}
if (flag == true)
Console.WriteLine("整数{0}是素数!", m);
else
Console.WriteLine("整数{0}不是素数!", m);
}
Console.ReadKey();
}

}
}[/sourcecode]

效果图:

暂无评论

发送评论 编辑评论


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
上一篇
下一篇