自己跑測資都是對的
不知到哪裡出錯了請大家指點
=======================以下為程式碼=====================
#include<iostream>
#include<stdlib.h>
#include<math.h>
using namespace std;
int main()
{
int x;
int count = 0;
while(cin>>x)
{
if(x < 1)
cout<<"非測資"<<endl;
if(x == 1)
cout<<"非質數"<<endl;
else
{
if(x<100)
{
for(int i = 2;i<x;i++)
{
if(x % i != 0)
continue;
else
count++;
}
if(count == 0)
cout<<"質數"<<endl;
else
cout<<"非質數"<<endl;
}
else
{
int test;
test = (int)sqrt(x);
for(int i = 2;i <test;i++)
{
if(x % i != 0)
continue;
else
count++;
}
if(count == 0)
cout<<"質數"<<endl;
else
cout<<"非質數"<<endl;
}
}
}
}