GerexD

ism3--6

Sep 20th, 2017
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. #include <iostream>
  2. #include <limits.h>
  3. ///szurjuk be a sor. legkisebb eleme ele a pozitiv szamok osszeget
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8. int a[50],n,min=INT_MAX, o=0;
  9. cout<<"N ";cin>>n;
  10. for(int i=1;i<=n;i++)
  11. cin>>a[i];
  12. for(int i=1;i<=n;i++)
  13. if(a[i]%2==0)o=o+a[i];
  14. for(int i=1;i<=n;i++)
  15. if(a[i]<min) min=a[i];
  16. for(int i=1;i<=n;i++)
  17. {
  18. if(a[i]==min)
  19. {
  20. int k=i;
  21. for(int j=n;j>=k;j--) a[j+1]=a[j];
  22. a[k]=o;
  23. n++;
  24. }
  25. }
  26. for(int i=1;i<=n;i++) cout<<a[i]<<" ";
  27. return 0;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment