Random matrix

From ATI public wiki
Jump to: navigation, search

Maatriksi genereerimine random funktsiooniga

#include <stdio.h>
#include <time.h>

#define MAX 15

void generateMatrix(int M[MAX][MAX], int n, int m) {
    int i, j;
    srand(time(NULL));
    for (i = 0; i < n; i++) {
      for (j = 0; j < m; j++) {
        M[i][j] = rand()%50;
      }
    }
}