Advertisement
Guest User

Untitled

a guest
Nov 22nd, 2017
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main() {
  6. double array[5][3];
  7. double rowSum[5] = {0, 0, 0, 0, 0};
  8. double minRow = 100;
  9. double maxRow = 0;
  10.  
  11. for (int i = 0; i < 5; ++i) {
  12. for (int j = 0; j < 3; ++j) {
  13. cout << "Enter number for position " << i << " | " << j << " = ";
  14. cin >> array[i][j];
  15. }
  16. }
  17.  
  18. cout << endl;
  19.  
  20. for (int i = 0; i < 5; ++i) {
  21. for (int j = 0; j < 3; ++j) {
  22. cout << array[i][j] << " | ";
  23. }
  24.  
  25. cout << endl;
  26. }
  27.  
  28. for (int i = 0; i < 5; ++i) {
  29. for (int j = 0; j < 3; ++j) {
  30. rowSum[i] = rowSum[i] + array[i][j];
  31. }
  32. }
  33.  
  34. for (int i = 0; i < 5; ++i) {
  35. if (maxRow < rowSum[i]){
  36. maxRow = rowSum[i];
  37. }
  38. }
  39.  
  40. for (int k = 0; k < 5; ++k) {
  41. if (rowSum[k] < minRow)
  42. {
  43. minRow = rowSum[k];
  44. }
  45. }
  46.  
  47. cout << endl << "Min: " << minRow << " max: " << maxRow << endl << endl;
  48. for (int i = 0; i < 5; i++){
  49. cout << "The sum of row " << i + 1 << " is " << rowSum[i] << endl;
  50. }
  51.  
  52.  
  53. cin >> array[1][2];
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement