fork download
  1. #include <iostream>
  2. //#include <cstdlib>
  3. using namespace std;
  4.  
  5. int main() {
  6. int evenSize;
  7. cin >> evenSize;
  8. int currentEl, firstHalfSum = 0, secondHalfSum = 0;
  9. for (int line = 1; line <= evenSize; ++line) {
  10. for (int col = 1; col <= evenSize; ++col) {
  11. cin >> currentEl;
  12. if (col <= evenSize / 2) {
  13. firstHalfSum += currentEl;
  14. } else {
  15. secondHalfSum += currentEl;
  16. }
  17. }
  18. }
  19. if (firstHalfSum > secondHalfSum) {
  20. cout << "Prima jumatate\n";
  21. } else {
  22. cout << "A doua jumatate\n";
  23. }
  24.  
  25. int sumDifference = firstHalfSum - secondHalfSum;
  26. if (sumDifference < 0) {
  27. sumDifference = -sumDifference;
  28. }
  29. cout << sumDifference;
  30.  
  31. //cout << abs(firstHalfSum - secondHalfSum);
  32. return 0;
  33. }
Success #stdin #stdout 0.01s 5272KB
stdin
8
9 8 7 6 5 4 3 2
9 8 7 6 5 4 3 2
9 8 7 6 5 4 3 2
9 8 7 6 5 4 3 2
9 8 7 6 5 4 3 2
9 8 7 6 5 4 3 2
9 8 7 6 5 4 3 2
9 8 7 6 5 4 3 2
stdout
Prima jumatate
128