VadimThink

Untitled

May 20th, 2020
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.36 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4. int main() {
  5.     setlocale(LC_ALL, "Rus");
  6.     bool isThere = false;
  7.     int** array;    
  8.     array = new int* [4];  
  9.     for (int i = 0; i < 4; i++) {  
  10.         array[i] = new int[4];
  11.     }
  12.     cout << "Enter numbers\n";
  13.     for (int i = 0; i < 4; i++) {
  14.         for (int j = 0; j < 4; j++) {
  15.             cout << "array [" << i + 1 << "][" << j + 1 << "] = ";
  16.             cin >> array[i][j];
  17.         }
  18.     }
  19.     cout << endl;
  20.  
  21.  
  22.     for (int i = 0; i < 4; i++) {
  23.         cout << endl;
  24.         for (int j = 0; j < 4; j++) {
  25.             cout << array[i][j] << " ";
  26.         }
  27.     }
  28.     int mult = 1;
  29.     for (int i = 1; i < 4; i++) {
  30.         if (array[0][i] < 0) {
  31.             mult *= array[0][i];
  32.             isThere = true;
  33.         }
  34.     }
  35.  
  36.     for (int i = 2; i < 4; i++) {
  37.         if (array[1][i] < 0) {
  38.             mult *= array[1][i];
  39.             isThere = true;
  40.         }
  41.     }
  42.    
  43.     if (array[2][3] < 0) {
  44.         mult *= array[2][3];
  45.         isThere = true;
  46.     }
  47.  
  48.     if (isThere) {
  49.         for (int i = 0; i < 4; i++) {
  50.             array[i][i] += mult;
  51.         }
  52.         for (int i = 0; i < 4; i++) {
  53.             cout << endl;
  54.             for (int j = 0; j < 4; j++) {
  55.                 cout << array[i][j] << ' ';
  56.             }
  57.         }
  58.     }
  59.     else {
  60.         cout << "\nТаких значений нет";
  61.     }
  62.    
  63.     return 0;
  64. }
Advertisement
Add Comment
Please, Sign In to add comment