C 我需要帮助

C 我需要帮助,c,C,谁能解释一下这是怎么回事 void matr(int arr[max][max], int n, int m){ int i, k; for (i = 0, k = m * n; i < k; i++) { arr[i / m][i % m] = rand() % 10 * (pow(-1, rand() % 10)); }} void matr(int arr[max][max],int n,int m){ int i,k; 对于(i=0,k=m*n;i

谁能解释一下这是怎么回事

void matr(int arr[max][max], int n, int m){

int i, k;
for (i = 0, k = m * n; i < k; i++)
{
    arr[i / m][i % m] = rand() % 10 * (pow(-1, rand() % 10));
}}
void matr(int arr[max][max],int n,int m){
int i,k;
对于(i=0,k=m*n;i
给定此代码:

void matr(int arr[max][max], int n, int m)
{

    int i;
    int k;

    for (i = 0, k = m * n; i < k; i++)
    {
        arr[i / m][i % m] = rand() % 10 * (pow(-1, rand() % 10));
    }
}
void matr(int arr[max][max],int n,int m)
{
int i;
int k;
对于(i=0,k=m*n;i
下面是一个解释:

1) MAX must be a #define or enum value  
   cannot be sure of which as that detail was not posted

2) `int arr[max][max]` is a pointer to a 2D array
   with max rows and max columns

3) `int n, int m` we can assume are the number or rows and columns to be filled in
   unfortunately with such extremely poor/meaningless parameter names
   it is difficult to be sure of their meaning.
   Also, both 'n' and 'm' must be <= 'max'

4) `int k;` should really have been: `int k = m*n;`
   and that calculation not placed in the 'for() statement, first parameter.
   why the whole 2D matrix is not being filled is a good/unanswered question.

5) `for (i = 0, k = m * n; i < k; i++)`  means loop m*n times with loop counter 'i'

6) `arr[i / m][i % m]`  this is a calculation of which row/column
   to place the produced value into.
   notice that this fills the matrix a row at a time
   however, if 'm' is not equal to 'n' then this calculation is flawed

7) `rand() % 10` get a number in the range 0...9 inclusive

8) `rand() % 10)` get a number in the range 0...9 inclusive

9) `(pow(-1, rand() % 10)` get the -1 to the 0...9 (inclusive) power
   which will produce both positive and negative values 
   depending on if the 'power' value is even or odd
1)MAX必须是#定义或枚举值
无法确定是哪个,因为该详细信息未发布
2) `int arr[max][max]`是指向二维数组的指针
最大行数和最大列数
3) `int n,int m`我们可以假设是要填充的行数或列数
不幸的是,参数名非常糟糕/毫无意义
很难确定它们的意思。

此外,“n”和“m”都必须是它在
-9范围内随机设置数组元素,但可以不使用
math.h
库,更简单地说,使用
rand()%19-9
。我们不是来教您C语言的。所以这个问题有点离题。问题应该是
帮助我,这不编译
帮助我,这给出了错误的输出