1
#include<iostream.h>
#include<conio.h>
#include<process.h>
main()
{
double a;
cout<<"Enter a number\n";
cin>>a;
for(int j=2;j<=a;j++)
if(a%j == 0)
{
cout<<"Its not a prime number\n";
exit(0);
}
else
cout<<"Its a prime number\n";
getch();
return 0;
}
我試着用int,long,char但是錯誤仍然存在.plz幫我解決它 – 2011-05-01 10:23:23
@Numair Siddique:你用'long a;'替換了'double a;'並且錯誤依然存在?難以置信。你編譯器所說的哪一行是錯誤? – DarkDust 2011-05-01 10:50:08
編譯器在這一行中給出了錯誤: - if(a%j == 0) – 2011-05-01 11:10:55