Advertisement
Guest User

supereasy

a guest
Jan 9th, 2020
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.66 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main() {
  6. int n, m,index=0;
  7. cin >> n >> m;
  8. float a[n][m],sum;
  9. float min_sum = 1000;
  10. for(int i = 0; i < n; i++)
  11. {
  12.   sum = 0;
  13. for(int j = 0; j < m; j++)
  14. {
  15. cin >> a[i][j];
  16. sum += a[i][j];
  17. }//end of j
  18. if (min_sum > sum)
  19. {
  20. min_sum = sum;
  21. index = i;
  22. }//end of if
  23. }//end of i
  24.  
  25. for (int i = 0; i < index + 1; i++)
  26. {
  27. for (int j = 0; j < m; j++)
  28. cout << a[i][j] << "";
  29. cout << "\n";
  30. }
  31.  
  32. for (int i = 0; i < m; i++)
  33. cout << 0 << " ";
  34. cout << "\n";
  35.  
  36. for (int i = index + 1; i < n; i++)
  37. {
  38. for(int j = 0; j < m; j++)
  39. cout << a[i][j] << "";
  40. cout << "\n";
  41. }//end of i
  42.  
  43. system("pause");
  44. return 0;
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement