|
|
вернуться в форумThis is my code.why it is wrong?Who can help me solve it?Thanks!!!! #include<iostream> #include<vector> using namespace std; int main(){ int N; cin>>N; int *a=new int [N]; vector<int*> b; vector<int*>::iterator it,it1; for(int i=0;i<N;i++) cin>>a[i]; for(int j=0;j<N;j++) b.push_back(a+j); for(it=b.begin();it!=b.end();it++) for(it1=it+1;it1!=b.end();it1++){ int *temp; if(**it>**it1){ temp=*it1; *it1=*it; *it=temp; } } int k=11,count=4; for(it=b.begin();it!=b.end();it++){ int m; m=**it; switch(m){ case 1:**it=2;break; case 2:**it=3;break; case 3:**it=5;break; case 4:**it=7;break; default :{ for(;count!=m;k=k+2){ if(k%3!=0 && k%5!=0 && k%7!=0) count++; } **it=k-2; } } } for(int y=0;y<N;y++) cout<<a[y]<<endl; return 0; } |
|
|