
檢驗質數算是寫C++中一件好玩又痛苦的事情吧~
在此分享我自己寫的檢測程式~給大家參考
此程式運行速率執行過你就知道了,給大家我的想法



#include<iostream>
using namespace std;
int main()
{
int in; //儲存輸入
while(true)
{
cout<<"Number:";
cin>>in;
for(unsigned int x=2;x<=in;x++)
{
while(in%x==0)
{
cout<<x<<"*";
in/=x;
}
}
cout<<"\b \n";
}
system("pause");
return 0;
}