Тема: Компілювання в C++ Shell та CodeBlocks
Доброго вечора!
Дано завдання:знайти максимальний елемент першого рядка масиву. Вивести на екран вихідний масив і новий, в якому всі додатні елементи помножено на знайдене число.
Мова програмування С++
Є код який працює коректно в онлай компіляторі C++ Shell, але коли його вставляєш в CodeBlocks на компі, то множення на максимальний елемент не відбувається. Чи може хтось пояснити в чому проблема?
#include <iostream>
#include <ctime> // в ній функція time
#include <stdlib.h>
using namespace std;
int main ()
{
    srand (time (NULL)); 
    int n, m, i, j;
    cout<<"Enter the number of rows ";
    cin >> n;
    cout<<"Enter the number of columns ";
    cin >> m; 
    int ** a = new int * [n]; 
    for (int i = 0; i <n; i ++)
    {
        a [i] = new int [n]; 
    }
 
    for (int i = 0; i <n; i ++)
    {
        for (int j = 0; j <m; j ++)
        {
            a [i] [j] = rand ()% 20; 
            cout << a [i] [j] <<"\t"; 
        } cout << endl;}
      
    int max_j=0, max_i=0  ;
    for (int i = 0; i <n; ++i)
     {for (int j = 0; j <m; ++j)
        if (a[0][j] > a[0][max_j])
        {max_i=i;
        max_j=j;
        }}
      int x;
        cout << "max = " <<a[max_i] [max_j]<< endl;
     x=a[max_i] [max_j];
     while(i<n)
    {
        while(j<m)
        {
            if (a[i][j]>=0)
                a[i][j]*=x;
            j++;
        }
        j=0;
        i++;
    }
    for(i=0;i<n;i++)
    {
        for(j=0;j<m;j++)
            cout<<a[i][j]<<"\t";
        cout<<"\n";}
     for (int i = 0; i <n; i ++)
    {
        delete [] a [i]; 
    }
    delete [] a; 
    return 0;}