Advertisement
Guest User

Untitled

a guest
Dec 7th, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.06 KB | None | 0 0
  1. #include <iostream>
  2. #include <conio.h>
  3. #define _CRT_SECURE_NO_WARNINGS
  4.  
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9.     int c[4][5];
  10.  
  11.     int jmax;
  12.     int sum = 0, sum_max = 0, temp = 0;
  13.  
  14.     for(int i = 0; i< 4; i++) //вовод массива
  15.     {
  16.         for(int j = 0; j < 5; j++)
  17.         {
  18.             cout << "Введите C[" << i << ' ' << j <<"]: ";
  19.             cin >> c[i][j];
  20.         }
  21.     }
  22.     cout << '\n';
  23.  
  24.     for(int j = 1 ; j < 5; j++)
  25.     {
  26.         sum = c[0][j]+c[1][j]+c[2][j]+c[3][j]+c[4][j]; //вычисление суммы
  27.         if(sum > sum_max)           //определение максимальной суммы
  28.         {
  29.             sum_max = sum;
  30.             jmax = j;
  31.         }
  32.     }
  33.  
  34.     for(int i = 0; i < 4; i++ )
  35.     {
  36.         temp = c[i][jmax];          //замена столбцов
  37.         c[i][0] = temp;
  38.     }
  39.  
  40.  
  41.     for(int i=0; i < 4; i++)
  42.     {
  43.         for(int j=0;j < 5;j++)
  44.         {
  45.             cout << c[i][j] << ' ';
  46.         }
  47.         cout << '\n';
  48.     }
  49.     getch();
  50.     return 0;
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement