BetaCodeShareBeta

by Code Solutions Project

Simple solutions for common problems

Description: Random square matrix from size
C/C++
MagRag
void fillMatrix(int matrix[DIM][DIM]) {
  int i, j;
  for(i = 0; i < DIM; i++) {
    for(j = 0; j < DIM; j++) {
      if(sopa[i][j] == ZERO) {
	sopa[i][j] = random(CHAR_MIN, CHAR_MAX);
      }
    }
  }
}

Input example

2

Output example

[[0.32 0.9]
 [0.45 0.23]]

Other implementations

Matlab
function [ A ] = randomMatrix( siz )
    A = rand(siz,siz)*10;
end

×Oh snap! Something wrong