Home > Back-end >  Ask questions about two-dimensional array call
Ask questions about two-dimensional array call

Time:11-16

#include
#include
Int * * Get2DArray (int row, int col) {
* * a, int l;
A=(int * *) calloc (row, sizeof (int *));
For (l=0; LA [l]=(int *) calloc (col, sizeof (int));
return a;
}

Int yasuo (int * o, int * * a, int n) {
int i,j;
for(i=0; ifor(j=0; jIf (i>=j)
A [I] [j]=o [I * (I + 1)/2 + j];
The else
A [I] [j]=o [j * (j + 1)/2 +] I;
}
}
Int * * multiple (int * o, int * p, * * c int, int n) {
Int I, j, k, l, d, s;
C=Get2DArray (n, n);
for(i=0; i{
for(j=0; j{
For (k=0; k{
If (i>=k)
L=(I + 1) * I/2 + k;
If (iL=(k + 1)/2 * k + I;
If (j>=k)
D=(j + 1) * 2 + j/k;
If (jD=(k + 1)/2 * k + j.
S + p=o [l] * [d].
}
C [I] [j]=s;
S=0;
}
}
return c;
}

/* run this program using the console pauser or add your own getch, system (" pause ") or the input loop */

Int main (int arg c, char * argv []) {
Int * o * p, * * a, b, * * * * c, n, I, k, j, l;
Printf (" please enter the order number n: \ n ");
The scanf (" % d ", & amp; N);
A=Get2DArray (n, n);
B=Get2DArray (n, n);
C=Get2DArray (n, n);
K=(1 + n) * n/2;
O=(int *) malloc (sizeof (int) * k);
P=(int *) malloc (sizeof (int) * k);

Printf (" generating matrix A, please input % d compression matrix of Numbers: \ n ", k);
For (l=0; iThe scanf (" % d ", & amp; O [l]);
Yasuo (o, a, n);
Printf (" matrix A is: \ n ");
for(i=0; ifor(j=0; jPrintf (" % d ", a [I] [j]);
If (j)==n - 1
printf("\n");
}

Printf (" generator matrix B please input % d compression matrix of Numbers: \ n ", k);
For (l=0; iThe scanf (" % d ", & amp; O [I]);
Yasuo (p, b, n);
Printf (" matrix B is: \ n ");
for(i=0; ifor(j=0; jPrintf (" % d, b [I] [j]);
If (j)==n - 1
printf("\n");
}

C=multiple (o, p, c, n);
Printf (" matrix for C: \ n ");
for(i=0; ifor(j=0; jPrintf (" % 5 d, c [I] [j]);
If (j)==n - 1
printf("\n"); }
return 0;
}
Run to draw
Want to effect

want to know why
  • Related