?? 求素數.txt
字號:
using System;
namespace Other_Features
{
public class Prime
{
public int number;
public Prime(int n)
{
if(isPrime(n))
this.number=n;
else
throw new Exception (n+" is not a prime.");
}
public static Prime operator ++ (Prime orig)
{
bool succeeded =false;
while(!succeeded)
succeeded=isPrime(++orig.number );
return orig;
}
public static bool isPrime(int number)
{
int max=(int)(number/2+1);
for(int i=2;i<max;++i)
if(number%i==0)
return false;
return true;
}
public static void Main()
{
Prime p=new Prime (1);
for(int i=0;i<100;++i)
{
Console.WriteLine (p.number);
++p;
}
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -