#include<iostream.h>
struct node
{
int p;
node*next;
};
node*ptr,*start=NULL,*Rear;
void fn()
{
if (start==NULL)
{
start=Rear=ptr;
}
else
{
Rear->next=ptr;
Rear=ptr;
}
}
void main()
{
unsigned long int m,n,i,j,a[10][2];
int t,flag=0,r;
cin>>t;
for(i=0;i<t;i++)
{
cin>>m>>n;
for (r=0;r<10;r++)
{
a[r][0]=m;
a[r][1]=n;
}
for (i=m;i<=n;i++)
{ for (j=2;j<=m/2;j++)
{
if (i%j==0)
{
flag=1;
break;
}
if (flag==1)
break;
}
if (flag==0)
ptr->p=i;
ptr->next=NULL;
fn();
}
}
for (r=0;r<10;r++)
{ cout<<"\n";
cout<<endl;
for (ptr=start;ptr->next!=NULL;ptr=ptr->next)
{
if (ptr->p>a[r][0]&&ptr->p<a[r][1])
{
cout<<ptr->p;cout<<"\n";
}
}
}
}
where am i going wrong?
created
last reply
- 24
replies
- 2.3k
views
- 11
users
- 1
like
- 3
links