mirror of
https://gitlab.com/klmp200/LO27.git
synced 2024-11-22 15:23:19 +00:00
Added example matrix
This commit is contained in:
parent
1735a21274
commit
f8bdbe19f4
@ -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);
|
||||||
}
|
}
|
14
matrixmain.c
14
matrixmain.c
@ -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);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user