Помогите C++. Дан двумерный массив целых чисел. Все отрицательные элементы массива умножить на первый элемент соответствующей строки.​

Ответы

Ответ дал: justmuve
1

#include <iostream>

#include <cstdlib>

#include <ctime>

using namespace std;

int main()

{

   const int n = 4;

   int a;

   int mas[n][n];

   srand(time(NULL));

   for (int i = 0; i < n; i++)

   {

       for (int j = 0; j < n; j++)

       {

           a = rand() % 11 - 5 ;

           mas[i][j] = a;

          cout.width(3);

            cout <<mas[i][j] <<" ";

       }

        cout <<endl;

   }

   cout <<endl;

   

for (int i = 0; i < n; i++)

  {

   for (int j = 0; j < n; j++)

     {

     if (mas[i][j]<0){

       mas[i][j]=mas[i][j]*mas[i][0];

       

       }

       cout.width(3);

       cout <<mas[i][j] <<" ";

     }

     cout <<endl;

  }  

   

   

   return 0;

}

Вас заинтересует