LO27/matrixmain.c

62 lines
1.5 KiB
C
Raw Normal View History

2016-12-10 01:28:10 +00:00
/*********************************************************************************
* File Name : main.c
* Created By : klmp200
* Creation Date : [2016-12-10 01:06]
* Last Modified : [2016-12-10 01:07]
2016-12-10 20:11:46 +00:00
* Description :
2016-12-10 01:28:10 +00:00
**********************************************************************************/
2016-12-28 20:39:42 +00:00
#include <SDL2/SDL.h>
2016-12-10 01:28:10 +00:00
#include <stdio.h>
#include <stdlib.h>
2016-12-13 14:12:55 +00:00
#include <matrix.h>
#include <gui.h>
2016-12-10 20:11:46 +00:00
2016-12-28 20:39:42 +00:00
int main(){
int rule;
int times;
bool useSDL;
bool cont = true;
int col;
int row;
2016-12-29 00:40:50 +00:00
Matrix m1;
2016-12-26 19:44:39 +00:00
Matrix m2;
BooleanMatrix bmatrix;
useSDL = YesOrNo("Do you want to use SDL library for matrix display ?");
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);
2016-12-26 19:44:39 +00:00
2016-12-28 20:39:42 +00:00
bmatrix = RandomizeBooleanMatrix(bmatrix);
m1 = newMatrix(bmatrix);
FreeBooleanMatrix(bmatrix);
2016-12-27 21:26:06 +00:00
DisplayMatrixGUI(m1, useSDL);
2016-12-28 20:39:42 +00:00
while (cont){
printf("What rule do you want to apply to this matrix ?\n");
rule = SafeNumberInput(1, 481);
printf("How many times do you want the rule to be applied ?\n");
times = SafeNumberInput(1, 100000);
m2 = applyRules(m1,rule,times);
freeMatrix(m1);
2016-12-29 00:40:50 +00:00
DisplayMatrixGUI(m2, useSDL);
cont = YesOrNo("Do you want to apply other rules on this matrix ?");
m1 = m2;
}
2016-12-29 00:40:50 +00:00
2016-12-26 19:44:39 +00:00
freeMatrix(m2);
2016-12-10 01:28:10 +00:00
return 0;
2016-12-10 20:11:46 +00:00
2016-12-10 01:28:10 +00:00
}