Home > Back-end >  Big trouble to help me see where is wrong, thank you very much.
Big trouble to help me see where is wrong, thank you very much.

Time:05-22


 # include & lt; stdio.h> 

int n;
Int Max (int row, int a [] [n], int n);
Int min (int column, int a [] [n], int n);

Int main (void)
{
The scanf (" % d ", & amp; N);
Int I, j, a, [n] [n].

For (I=0; I & lt; n; I++)
{
For (j=0; J & lt; n; J++)
{
The scanf (" % d ", & amp; A [I] [j]);
//if (j!=n - 1)
//the scanf (" ");
}
//the scanf (" \ n ");
}

For (I=0; I & lt; n; I++)
{
If (I==min (Max (I, a, n), a, n))
{
Printf (" % d % d ", I, Max (I, a, n));
goto end;
}
}
Printf (" NO ");

End: return 0;
}

Int Max (int row, int a [] [n], int n)
{
Int I, column=0;
for (i=1; I & lt; n; I++)
{
If (a [row] [I] & gt; A/the row/column)
The column=I;
}
Return the column;
}

Int min (int column, int a [] [n], int n)
{
Int I, a row=0;
for (i=1; I & lt; n; I++)
{
If (a [I] [column] The row=I;
}
Return the row.
}

CodePudding user response:

Old compiler doesn't support dynamic size variable n as an array subscript statement,

CodePudding user response:

reference 1/f, zhao teacher reply:
old compiler doesn't support dynamic size variable n as an array subscript statement,

I configured the MinGW GCC 11.1.0, could you tell me how or an error?

CodePudding user response:

Suggest or honestly to use new and delete and new [], the delete [] way to create/destroy dynamic array,

CodePudding user response:

Or simply use the STL vector

CodePudding user response:

C + + does not support variables to create an array, not a compiler problem, the solution with upstairs

CodePudding user response:

reference 5 floor 4 teacher zhao reply:
or simply use the STL vector

STL vector is for the use of c + +, I write of is the c language, this new and delete I checked the, not using, could you please help me to change the code? Thank you very much,

CodePudding user response:

Modified as follows, for your reference:
 # include & lt; stdio.h> 


Int Max (int row, int * * a, int n);
Int min (int column, int * * a, int n);

Int main (void)
{
int n;
Int I, j, * * a;//a, [n] [n].
The scanf (" % d ", & amp; N);

A=new int * [n].
for(i=0; i
For (I=0; I & lt; n; I++)
{
For (j=0; J & lt; n; J++)
{
The scanf (" % d ", & amp; A [I] [j]);
//if (j!=n - 1)
//the scanf (" ");
}
//the scanf (" \ n ");
}

For (I=0; I & lt; n; I++)
{
If (I==min (Max (I, a, n), a, n))
{
Printf (" % d % d ", I, Max (I, a, n));
goto end;
}
}
Printf (" NO ");

End:
for(i=0; iThe delete [] a;

return 0;
}

Int Max (int row, int * * a, int n)
{
Int I, column=0;
for (i=1; I & lt; n; I++)
{
If (a [row] [I] & gt; A/the row/column)
The column=I;
}
Return the column;
}

Int min (int column, int * * a, int n)
{
Int I, a row=0;
for (i=1; I & lt; n; I++)
{
If (a [I] [column]
The row=I;
}
Return the row.
}
  • Related