Jim

Simple matrix program without threads.

Showing 1 changed file with 45 additions and 0 deletions
#include <stdio.h>
#include <stdlib.h>
int main(){
double **matrix;
int i,j,m,n;
m = 12;
n = 12;
if ( (matrix = (double **) malloc(m * sizeof(double *))) == NULL ) {
printf ("malloc failed\n");
return -1;
}
for (i = 0; i < m; i++){
if ( ( matrix[i] = (double *)malloc (n * sizeof(double))) == NULL ) {
printf ("malloc failed\n");
return -2;
}
for (j = 0; j < n; j++){
matrix[i][j] = 1;
}
}
for (i = 0; j < m; i++){
for (j = 0; j < n; j++){
printf ("%f", matrix[i][j]);
}
printf("\n");
}
for (i = 0; i < m; i++)
free (matrix[i]);
free (matrix);
return 0;
}
... ...