Advertisement
Guest User

s

a guest
Feb 18th, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3.  
  4. using namespace std;
  5.  
  6. void IGORLOH(int m[], int n)
  7. {
  8. int i, j, t;
  9. for (i=0;i<n-1;i++)
  10. for(j=0;j<n-i-1;j++)
  11. if (m[j]<=m[j+1])
  12. {
  13. t=m[j];
  14. m[j]=m[j+1];
  15. m[j+1]=t;
  16. }
  17.  
  18. }
  19.  
  20. int main()
  21. {
  22. int c[20];
  23. int A_Sum=0;
  24. int B_Sum=0;
  25. int n;
  26. cin>>n;
  27. for (int i=0; i<n; i++)
  28. {
  29. cin>>c[i];
  30. }
  31. IGORLOH(c,n);
  32. for (int i=0; i<n; i++)
  33. {
  34. if (A_Sum<=B_Sum)
  35. {
  36. A_Sum+=c[i];
  37. }
  38. else
  39. {
  40. B_Sum+=c[i];
  41. }
  42. }
  43. cout<<abs(A_Sum-B_Sum);
  44. return 0;
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement