1
0
mirror of https://gitlab.com/klmp200/LO27.git synced 2024-11-26 00:04:14 +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){ void setRowToTrue(Matrix matrix, int RowNb){
int i =0; int i =0;
for (i=0;i<m2.colCount;i++){ for (i=0;i<matrix.colCount;i++){
setCellValue(matrix,i,RowNb); setCellValue(matrix,i,RowNb,true);
} }
} }
void setColToTrue(Matrix matrix, int ColNb){ void setColToTrue(Matrix matrix, int ColNb){
int i =0; int i =0;
for (i=0;i<m2.rowCount;i++){ for (i=0;i<matrix.rowCount;i++){
setCellValue(matrix,ColNb,i); setCellValue(matrix,ColNb,i,true);
} }
} }
void createSquare(Matrix matrix){ void createSquare(Matrix matrix){
setRowToTrue(matrix,rowCount/4); setRowToTrue(matrix,matrix.rowCount/4);
setRowToTrue(matrix,rowCount*3/4); setRowToTrue(matrix,matrix.rowCount*3/4);
setColToTrue(matrix,colCount/4); setColToTrue(matrix,matrix.colCount/4);
setColToTrue(matrix,colCount*3/4); setColToTrue(matrix,matrix.colCount*3/4);
} }

View File

@ -38,6 +38,19 @@ int main(){
BooleanMatrix bmatrix; BooleanMatrix bmatrix;
useSDL = inputYesOrNo("Do you want to use SDL library for matrix display ( interesting for big matrix only ) ?"); useSDL = inputYesOrNo("Do you want to use SDL library for matrix display ( interesting for big matrix only ) ?");
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);
m1 = createMatrix();
m1 = setMatrixDim(m1,col,row);
createSquare(m1);
}else{
printf("A random matrix will be generated\n"); printf("A random matrix will be generated\n");
printf("Enter the number of columns of this matrix\n"); printf("Enter the number of columns of this matrix\n");
col = safeNumberInput(1, 30000); col = safeNumberInput(1, 30000);
@ -48,6 +61,7 @@ int main(){
bmatrix = randomizeBooleanMatrix(bmatrix); bmatrix = randomizeBooleanMatrix(bmatrix);
m1 = newMatrix(bmatrix); m1 = newMatrix(bmatrix);
freeBooleanMatrix(bmatrix); freeBooleanMatrix(bmatrix);
}
displayMatrixGUI(m1, useSDL); displayMatrixGUI(m1, useSDL);