#include
#include
using namespace std;
int isPrime( long n) {
int i,k;
if (n<2) return 0;
k=(int)sqrt(n);
for (i=2; i<=k; i++){
if ((n%i) != 0 ) continue;
return 0;
}
return 1;
}
int main() {
long i,a,b;
do {
system("cls");
cout <<"\n\nEnter two numbers : ";
cin >> a >> b;
if (a > b) swap(a,b);
cout <<"\n\nThe prime numbers between ( and \n";
cout << " including ) "<< a << " and " << b << " are : \n\n";
for (i=a; i<=b; i++) {
if (isPrime(i)==1) printf("%d ,",i);
}
cout << "\n\n";
system("pause");
} while (1 != 2);
return 0;
}
2006-07-30 23:00:59
·
answer #1
·
answered by iyiogrenci 6
·
0⤊
0⤋