You are viewing a single comment's thread. Return to all comments →
`#include
using namespace std;
int arr[1200]; void prime_no() {
int count=1; for(int i=2; i<=10000; i++) { /* int i; cin>>i; */ if(i==2||i==3) { //cout<<i<<" "; arr[count++]=i; //count++; } else { int flag=1; for(int j=2; j<=sqrt(i); j++) { if(i%j==0) { flag=0; break; } } if(flag) { // cout<<i<<" "; arr[count++]=i; //count++; } //else //cout<<"Not prime"<<endl; }
}
int main() { prime_no();
int n,q; cin>>n>>q; int arr1[100000]; int top1=-1; for(int i=0; i<n; i++) cin>>arr1[++top1]; int arr2[100000]; int top2=-1; int arr3[100000]; int top3=-1; int arr4[100000]; int top4=-1; for(int i=1; i<=q; i++) { while(top1>=0) { int temp=arr1[top1--]; //cout<<"temp= "<<temp<<endl; if(temp%arr[i]==0) arr2[++top2]=temp; else arr3[++top3]=temp; } for(int i=top2; i>=0; i--) { // int temp=arr2[top2--]; arr4[++top4]=arr2[i]; } top2=-1; for(int i=0; i<=top3; i++) { int temp=arr3[i]; arr1[++top1]=temp; } top3=-1; }
//cout<<"output= "<
// cout<<"2nd list"<=0; i--) cout<
}`
Seems like cookies are disabled on this browser, please enable them to open this website
Waiter
You are viewing a single comment's thread. Return to all comments →
`#include
using namespace std;
int arr[1200]; void prime_no() {
}
}
int main() { prime_no();
//cout<<"output= "<
// cout<<"2nd list"<=0; i--) cout<
}`