Problem with array program

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.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#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;
}
Hello lollos97boom,

Welcome to the forum.

The compiler says 'n' was not declared in this scope and i don't know why.
I do not know why either. Which "n" is it talking about? Post the entire error message so it can be seen which "n" is the problem.

Line 42 is a problems. This is not an array definition. See http://www.cplusplus.com/doc/tutorial/arrays/ Also you can not use "n" and "m" the way you are to define a 2D array. These values need to be a constant number at compile time. To use "n" and "m" you would need to create a dynamic array.

Lines 46 and 47 is not the way to call a function with an array. Only the array name is needed in the function call.

Lines 4 and 20 are not the correct way of receiving an array.

Read the tutorial above and if you have any more questions let me know.

Hope that helps,

Andy
Thank you so much for your response. I will try what you said and i will let you know if i have any problems.
Topic archived. No new replies allowed.