1
0
mirror of https://gitlab.com/klmp200/LO27.git synced 2024-12-22 07:11:08 +00:00

Added example matrix

This commit is contained in:
Naej 2017-01-02 01:16:49 +01:00
parent 1735a21274
commit f8bdbe19f4
2 changed files with 31 additions and 17 deletions

View File

@ -668,23 +668,23 @@ bool equalsMatrix(Matrix m1, Matrix m2){
void setRowToTrue(Matrix matrix, int RowNb){
int i =0;
for (i=0;i<m2.colCount;i++){
setCellValue(matrix,i,RowNb);
for (i=0;i<matrix.colCount;i++){
setCellValue(matrix,i,RowNb,true);
}
}
void setColToTrue(Matrix matrix, int ColNb){
int i =0;
for (i=0;i<m2.rowCount;i++){
setCellValue(matrix,ColNb,i);
for (i=0;i<matrix.rowCount;i++){
setCellValue(matrix,ColNb,i,true);
}
}
void createSquare(Matrix matrix){
setRowToTrue(matrix,rowCount/4);
setRowToTrue(matrix,rowCount*3/4);
setColToTrue(matrix,colCount/4);
setColToTrue(matrix,colCount*3/4);
setRowToTrue(matrix,matrix.rowCount/4);
setRowToTrue(matrix,matrix.rowCount*3/4);
setColToTrue(matrix,matrix.colCount/4);
setColToTrue(matrix,matrix.colCount*3/4);
}

View File

@ -38,17 +38,31 @@ int main(){
BooleanMatrix bmatrix;
useSDL = inputYesOrNo("Do you want to use SDL library for matrix display ( interesting for big matrix only ) ?");
printf("A random matrix will be generated\n");
printf("Enter the number of columns of this matrix\n");
col = safeNumberInput(1, 30000);
printf("Enter the number of rows of this matrix\n");
row = safeNumberInput(1, 30000);
bmatrix = createBooleanMatrix(col, row);
printf("Do you prefer : 1. A matrix with random values 2. An example matrix\n");
if (safeNumberInput(1, 2) == 2){
printf("Enter the number of columns of this matrix\n");
col = safeNumberInput(1, 30000);
printf("Enter the number of rows of this matrix\n");
row = safeNumberInput(1, 30000);
bmatrix = randomizeBooleanMatrix(bmatrix);
m1 = newMatrix(bmatrix);
freeBooleanMatrix(bmatrix);
m1 = createMatrix();
m1 = setMatrixDim(m1,col,row);
createSquare(m1);
}else{
printf("A random matrix will be generated\n");
printf("Enter the number of columns of this matrix\n");
col = safeNumberInput(1, 30000);
printf("Enter the number of rows of this matrix\n");
row = safeNumberInput(1, 30000);
bmatrix = createBooleanMatrix(col, row);
bmatrix = randomizeBooleanMatrix(bmatrix);
m1 = newMatrix(bmatrix);
freeBooleanMatrix(bmatrix);
}
displayMatrixGUI(m1, useSDL);
while (cont){