使用平台 Dev-C++
#include <iostream>
#include <math.h>
using namespace std;
int main ()
{
int x,y;
while(cin >> y)
{
x = 2;
while ( x <= pow(y,0.5))
{
if ( y%x == 0 )
{
break;
}
x = x + 1;
}
if ( x <= pow(y,0.5))
{
cout << "非質數" <<"\n";
}
else
{
cout << "質數" << "\n";
}
}
}
初次發文
請多多指教
|