Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #define M_ROWS 20
- #define M_COLS 30
- #define D_FORMAT "%8.3f"
- void printDoubleMatrix(double **mtx, int rows, int cols)
- {
- printf("%8.3f", mtx[2][2]);
- }
- void generateMatrix(double ***mtx, int rows, int cols)
- {
- *mtx = (double **)calloc(rows, sizeof(double *));
- int i = 0, j = 0;
- if(!mtx)
- {
- printf("mtx == NULL\n");
- return;
- }
- for(i = 0; i < rows; i++)
- {
- (*mtx)[i] = (double *)calloc(cols, sizeof(double));
- for(j = 0; j < cols; j++)
- {
- (*mtx)[i][j] = (i * j - 1);
- }
- }
- }
- int main(int argc, char* argv[])
- {
- double **Matrix = NULL;
- generateMatrix(&Matrix, 4, 5);
- printDoubleMatrix(Matrix, 4, 5);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement