Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- int a[]={-1,1,2,0,-5,0,-7};
- const int N=6;
- int negative=0,nulls=-1,min=0,maxnegative=0;
- for (int i=0;i<N;++i)
- {
- if (a[i]>0 && (a[i]<a[min]||a[min]<=0))
- min=i;
- else if (a[i]==0)
- {
- if (nulls==-1) nulls=i;
- else {
- for (int i=0;i<N;++i)
- if (i!=nulls) cout<<a[i]<<" ";
- return 0;
- }
- }
- else if (a[i]<0)
- {
- ++negative;
- if (a[i]>a[maxnegative] || a[maxnegative]>=0) maxnegative=i;
- }
- }
- if (negative%2==0)
- {
- if (nulls!=-1)
- {
- for (int i=0;i<N;++i)
- if (i!=nulls) cout<<a[i]<<" ";
- }
- else {
- for (int i=0;i<N;++i)
- if (i!=min) cout<<a[i]<<" ";
- }
- }
- else if(negative%2)
- {
- for (int i=0;i<N;++i)
- if (i!=maxnegative) cout<<a[i]<<" ";
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement