-2

I wrote this program for the college. The user must input 2 numbers (n,m) and the program must make an array with the size [n,m]. Then the user will fill the array and the program must find the maximum number of the columns and print the minimum of them. Then it must find the minimum number of the lines and print the maximum. The compiler says 'n' was not declared in this scope and i don't know why. Can you help me? Thank's in advance.

#include <iostream>
using namespace std;

void max (int pinakas[n,m]) {
  int i,j,max,pinm[m],min;
  for (j=0; j<m; j++){
    max=pinakas[0,j];
    for (i=0; i<n; i++)
      if  (pinakas[i,j]>max)
        max=pinakas[i,j];
    pinm[j]=max;
  }
  min=pinm[0];
  for (j=0; j<m; j++)
    if (pinm[j]<min)
      min=pinm[j];
  cout << min;
}

void min (int pinakas[n,m]) {
  int i,j,max,pinm[n],min;
    for (i=0; i<n; i++){
      min=pinakas[i,0];
      for (j=0; j<m; j++)
        if  (pinakas[i,j]<min)
         min=pinakas[i,j];
      pinm[i]=min;
    }
    max=pinm[0];
    for (i=0; i<n; i++)
      if (pinm[i]>max)
       max=pinm[i];
    cout << max;
}



int main (){
  int n,m,i,j;

  cin >> n >> m;
  int pin[n,m];
  for (i=0; i<n; i++)
     for (j=0; j<m; j++)
        cin >> pin[i,j];
  max(pin[n,m]);
  min(pin[n,m]);
  return 0;
}
  • 1
    @OriBS not at all. OP is trying to use VLAs, which don't exist in C++. The syntax is also messed up (`[n, m]` instead of `[n][m]`). – Quentin Nov 21 '17 at 12:00
  • 1
    There is a good list of introductory books [here](https://stackoverflow.com/questions/388242/the-definitive-c-book-guide-and-list). – molbdnilo Nov 21 '17 at 13:30

1 Answers1

-1

You have tones of errors on your code. I suggest you to give a look at parameters in functions and variable declarations.

Lomezno
  • 90
  • 11