PROBLEM : http://www.spoj.com/problems/PRIME1/
MY SOURCE CODE:::::: IN GNU G++11 5.1.0
include <bits/stdc++.h>
using namespace std;
void prime(int low,int high) {
int flag=0,i,temp;
if (low > high) {
temp = low;
low = high;
high = temp;
}
while (low <=high)
{
flag = 0;
for(i = 2; i <= low/2; ++i)
{
if(low % i == 0)
{
flag = 1;
break;
}
}
if (flag == 0 && low!=1)
cout<<low<<endl;
++low;
}
} int main() { long long int n,a,b; cin>>n; while(n--) { cin>>a>>b;prime(a,b);cout<<endl; } return 0; }
Please can anyone correct my solution or tell me the problem in my code......thanks in advance :)