From ec63871214e110b56918cee236b235f31a28466a Mon Sep 17 00:00:00 2001 From: Sprinter05 Date: Thu, 7 Mar 2024 11:22:10 +0100 Subject: [PATCH 01/11] Implementado el ejercicio 8 --- src/Boletin_4/Ejercicio_08.c | 38 ++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 src/Boletin_4/Ejercicio_08.c diff --git a/src/Boletin_4/Ejercicio_08.c b/src/Boletin_4/Ejercicio_08.c new file mode 100644 index 0000000..f48db32 --- /dev/null +++ b/src/Boletin_4/Ejercicio_08.c @@ -0,0 +1,38 @@ +// SPDX-License-Identifier: GPL-3.0-only +#include +#define N 10 + +/*Design and implement a program in C language, by sequential search allow +finding the lowest and the highest index were a given X can be found into an +array of integers. The program should allow the user to properly enter the array +of integers and ask for the value you want to find.*/ + +int main(){ + // Define variables and ask for parameters + int nums[N], guess, lGuess, uGuess; + printf("\nInput an array of 10 elements by pressing Enter after each element: "); + for(int i=0; i<10; i++){ + scanf("%d", &nums[i]); + } + // Input guess + printf("\nWhat number do you want to find?: "); + scanf("%d", &guess); + // Lower bound + for(int i=0; i=0; i--){ + if(nums[i] == guess){ + uGuess = i; + break; + } + } + // Print solutions + printf("\nLower bound solution: %d", lGuess); + printf("\nUpper bound solution: %d", uGuess); + printf("\n"); +} \ No newline at end of file From b5fb7ad445aa4eb5a50f5a75b99e6ea6e7d24f36 Mon Sep 17 00:00:00 2001 From: Sprinter05 Date: Thu, 7 Mar 2024 11:24:00 +0100 Subject: [PATCH 02/11] Implementado el ejercicio 11 --- src/Boletin_4/Ejercicio_11.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 src/Boletin_4/Ejercicio_11.c diff --git a/src/Boletin_4/Ejercicio_11.c b/src/Boletin_4/Ejercicio_11.c new file mode 100644 index 0000000..e34aa6a --- /dev/null +++ b/src/Boletin_4/Ejercicio_11.c @@ -0,0 +1,30 @@ +// SPDX-License-Identifier: GPL-3.0-only +#include + +/*Design and implement a recursive function in C language that returns +the sum of the elements of an array of integers.*/ + +// Sum all the elements of the array using recursion +int arraySum(int n, int sumNums[n], int loops, int accum){ + if (loops == 0){return accum;} else{ + accum+=sumNums[n-loops]; + loops--; + arraySum(n, sumNums, loops, accum); + } +} + +int main(){ + // Define variables and ask for parameters + int n = 10; + int toSum[n], accum = 0, loops = n; + int result; + printf("Input the 10 numbers for the array separated by Enter:\n"); + for(int i=0; i<10; i++){ + scanf("%d", &toSum[i]); + } + // Recursion fun starts here + result = arraySum(n, toSum, loops, accum); + // Print result + printf("\nThe result of the sum is %d\n", result); + return 0; +} \ No newline at end of file From 4c2f0ddf94076409bbb9d4e6bae23456f5d0a40c Mon Sep 17 00:00:00 2001 From: Sprinter05 Date: Thu, 7 Mar 2024 11:26:26 +0100 Subject: [PATCH 03/11] Implementado el ejercicio 27 --- src/Boletin_4/Ejercicio_27.c | 48 ++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 src/Boletin_4/Ejercicio_27.c diff --git a/src/Boletin_4/Ejercicio_27.c b/src/Boletin_4/Ejercicio_27.c new file mode 100644 index 0000000..b073a59 --- /dev/null +++ b/src/Boletin_4/Ejercicio_27.c @@ -0,0 +1,48 @@ +// SPDX-License-Identifier: GPL-3.0-only +#include +#define N 100 + +/*Design and implement a program in C language to read a sentence +(maximum 100 characters) and then showing every word of it followed +by the number of letters that compose it. For simplicity, assume that +the words can be separated only by spaces, commas or periods.*/ + +// Count the amount of characters in the string +void countString(char toCount[N]){ + int count = 0; + for(int i=0; toCount[i]!='\0'; i++){ + count++; + } + printf("Word %s has %d characters\n", toCount, count); +} + +// Separate the string and fix multiple separators in the string by ignoring them +void separateString(char toSplit[N]){ + char splitted[N][N]; + int count=0, row=0, column=0; + while(toSplit[count] != '\n'){ + if(toSplit[count] == ' ' || toSplit[count] == ',' || toSplit[count] == '.'){ + splitted[row][column] = '\0'; + column = 0; + if (toSplit[count-1] != ' ' && toSplit[count-1] != ',' && toSplit[count-1] != '.'){row++;} + } else { + splitted[row][column] = toSplit[count]; + column++; + } + count++; + } + for(int i=0; splitted[i][0] != '\0'; i++){ + countString(splitted[i]); + } +} + +int main(){ + // Define variables and ask for parameters + char sentence[N]; + printf("Type a sentence of max 100 characters:\n"); + // fgets instead of gets for buffer overflow protection + fgets(sentence, N, stdin); + // Start the fun + separateString(sentence); + return 0; +} \ No newline at end of file From b97d47d4dfd17824f12e8e435ccf0fe2702a53fa Mon Sep 17 00:00:00 2001 From: Sprinter05 Date: Thu, 7 Mar 2024 11:29:22 +0100 Subject: [PATCH 04/11] Implementado el ejercicio 28 --- src/Boletin_4/Ejercicio_28.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 src/Boletin_4/Ejercicio_28.c diff --git a/src/Boletin_4/Ejercicio_28.c b/src/Boletin_4/Ejercicio_28.c new file mode 100644 index 0000000..7c70500 --- /dev/null +++ b/src/Boletin_4/Ejercicio_28.c @@ -0,0 +1,31 @@ +// SPDX-License-Identifier: GPL-3.0-only +#include +#define N 256 + +/*Design and implement a program in C language to read a phrase (sequence of +characters to end of line), replace all sequences of two or more spaces with +a single space and the show the modified phrase.*/ + +int main(){ + // Define variables and ask for parameters + int i=0, j=0; + char sentence[N], fixedSentence[N]; + printf("Type a sentence\n"); + // fgets instead of gets for buffer protection + fgets(sentence, N, stdin); + // Fix the sentence's multiple spaces + while(sentence[i]!='\0'){ + if(sentence[i] == ' ' && sentence[i+1] == ' '){ + i++; + continue; + } else { + fixedSentence[j]=sentence[i]; + i++; + j++; + } + } + // Print the result after apprending the end of string to the fixed variable + fixedSentence[j+1] = '\0'; + printf("\nThe sentence with fixed spaces is:\n%s", fixedSentence); + return 0; +} \ No newline at end of file From 88a46603994757ff8e66298a4cd13d4814917bf0 Mon Sep 17 00:00:00 2001 From: Sprinter05 Date: Thu, 7 Mar 2024 11:31:47 +0100 Subject: [PATCH 05/11] Implementado el ejercicio 36 --- src/Boletin_4/Ejercicio_36.c | 48 ++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 src/Boletin_4/Ejercicio_36.c diff --git a/src/Boletin_4/Ejercicio_36.c b/src/Boletin_4/Ejercicio_36.c new file mode 100644 index 0000000..fd378d9 --- /dev/null +++ b/src/Boletin_4/Ejercicio_36.c @@ -0,0 +1,48 @@ +// SPDX-License-Identifier: GPL-3.0-only +#include +#include +#define N 100 + +/*Implement a program that ask for five integers (ni > 0) and display each number and +factorial decomposition. Use a suitable data structure to store both the numbers +and decompositions.*/ + +void factorialDecomp(int toDecomp){ + int factors[N], primes=2, loops=0, og=toDecomp; + // Check if its 1 or 0 and just print out that the decomp is 1 + if(toDecomp == 0 | toDecomp == 1){ + printf("\nNumber %d factorial decomposition is: 1", og); + return; + } + // Repeat the factorization with each reduced number until its 0 + for(int i=0;i Date: Thu, 7 Mar 2024 11:33:55 +0100 Subject: [PATCH 06/11] Implementado el ejercicio 37 --- src/Boletin_4/Ejercicio_37.c | 49 ++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 src/Boletin_4/Ejercicio_37.c diff --git a/src/Boletin_4/Ejercicio_37.c b/src/Boletin_4/Ejercicio_37.c new file mode 100644 index 0000000..31275c9 --- /dev/null +++ b/src/Boletin_4/Ejercicio_37.c @@ -0,0 +1,49 @@ +// SPDX-License-Identifier: GPL-3.0-only +#include +#define N 11 +#define M 100 + +/*Implement a program that reads a date and store it in a string that +fit your 10 characters (dd/mm/yyyy) adding zeros to the left of the day, +month and year if needed, and calculate and store in memory the next 100 leap years. +The program should give the user the option to change the date entered and +see on the screen the n leap years from the given date.*/ + +void checkLeaps(int n, int year){ + int closeLeap, leaps[M], counter=1; + //Check closest + for(int i=0;i<4;i++){ + if((year+i)%4 == 0){ + closeLeap = year+i; + break; + } + } + // Get all the following leap years until the max amount is satisfied + leaps[0]=closeLeap; + while(counter != 100){ + leaps[counter]=closeLeap+(4*counter); + counter++; + } + // Print results + printf("\nFollowing 100 leap years:\n"); + for(int i=0; i Date: Thu, 7 Mar 2024 13:13:43 +0100 Subject: [PATCH 07/11] Implemented Exercise 40 --- src/Boletin_4/Ejercicio_40.c | 185 +++++++++++++++++++++++++++++++++++ 1 file changed, 185 insertions(+) create mode 100644 src/Boletin_4/Ejercicio_40.c diff --git a/src/Boletin_4/Ejercicio_40.c b/src/Boletin_4/Ejercicio_40.c new file mode 100644 index 0000000..2fabec5 --- /dev/null +++ b/src/Boletin_4/Ejercicio_40.c @@ -0,0 +1,185 @@ +// SPDX-License-Identifier: GPL-3.0-only +#include // Main library +#include // For managing the program +#include // Bool function +#include // Use UNIX commands +#include // For random numbers +#define N 16 // Change this number to change the matrix size +#define SPEED 2 // Higher means faster: MUST BE GREATER OR EQUAL THAN 1 +#define clear() printf("\033[H\033[J") // Clean screen + +/*Design and implement a program in C language to simulate the game of life of John Conway.*/ + +// NOTE: RUN FROM VSCODE TERMINAL OR THE MODERN WINDOWS TERMINAL APP NOT CMD OTHERWISE UTF-8 EMOJIS WILL NOT DISPLAY +// ALSO MAKE SURE UTF-8 SUPPORT IS ENABLED IN YOUR TERMINAL OF CHOICE, APPLIES TO ALL OPERATING SYSTEMS + +int gameOfLife[N][N]; +int updatedGame[N][N]; +int ticks=0; // Generations + +// THIS IS THE MATRIX THAT WILL RUN IF THE OPTION c (choose) IS CHOSEN AT RUNTIME +// THIS EXAMPLE MATRIX IS OF SIZE 16X16 SO IF YOU CHANGE N MODIFY THE SIZE HERE TOO +// 0 = DISABLED, 1 = ENABLED +int chooseGameOfLife[N][N] = { + {1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, + {1,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0}, + {0,0,1,1,0,0,0,1,0,0,1,0,0,0,0,0}, + {0,0,1,1,0,0,0,1,0,0,1,0,0,0,0,0}, + {0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0}, + {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, + {0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0}, + {0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0}, + {0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0}, + {0,0,0,1,1,1,1,0,0,0,0,0,0,0,0,0}, + {0,0,1,0,0,0,1,0,0,0,0,0,0,0,0,0}, + {0,0,0,0,0,0,1,0,0,0,1,1,0,0,0,0}, + {0,0,1,0,0,1,0,0,0,0,1,0,1,0,0,0}, + {0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0}, + {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, + {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0} +}; + +// Make sure the cell is not outsided of the matrix +bool outOfBound(int row, int column){ + bool oob; + if(row >= N || row < 0 || column >= N || column < 0){oob = true;} + else {oob = false;} + return oob; +} + +// Check rules 1, 2 and 3 for death status +void checkDeath(int row, int column){ + int liveNeighbours=0; + // Check neighbours + if(outOfBound(row+1,column) == false){if(gameOfLife[row+1][column] == 1){liveNeighbours++;}} + if(outOfBound(row+1,column+1) == false){if(gameOfLife[row+1][column+1] == 1){liveNeighbours++;}} + if(outOfBound(row+1,column-1) == false){if(gameOfLife[row+1][column-1] == 1){liveNeighbours++;}} + if(outOfBound(row-1,column) == false){if(gameOfLife[row-1][column] == 1){liveNeighbours++;}} + if(outOfBound(row-1,column+1) == false){if(gameOfLife[row-1][column+1] == 1){liveNeighbours++;}} + if(outOfBound(row-1,column-1) == false){if(gameOfLife[row-1][column-1] == 1){liveNeighbours++;}} + if(outOfBound(row,column+1) == false){if(gameOfLife[row][column+1] == 1){liveNeighbours++;}} + if(outOfBound(row,column-1) == false){if(gameOfLife[row][column-1] == 1){liveNeighbours++;}} + // Any live cell with fewer than two live neighbours dies, as if by underpopulation. + if(liveNeighbours<2){updatedGame[row][column]=0;} + // Any live cell with two or three live neighbours lives on to the next generation. + else if(liveNeighbours>=2 && liveNeighbours<=3){updatedGame[row][column]=1;} + // Any live cell with more than three live neighbours dies, as if by overpopulation. + else if(liveNeighbours>3){updatedGame[row][column]=0;} +} + +// Check rule 4 for revive status +void checkRevive(int row, int column){ + int liveNeighbours=0; + // Check neighbours + if(outOfBound(row+1,column) == false){if(gameOfLife[row+1][column] == 1){liveNeighbours++;}} + if(outOfBound(row+1,column+1) == false){if(gameOfLife[row+1][column+1] == 1){liveNeighbours++;}} + if(outOfBound(row+1,column-1) == false){if(gameOfLife[row+1][column-1] == 1){liveNeighbours++;}} + if(outOfBound(row-1,column) == false){if(gameOfLife[row-1][column] == 1){liveNeighbours++;}} + if(outOfBound(row-1,column+1) == false){if(gameOfLife[row-1][column+1] == 1){liveNeighbours++;}} + if(outOfBound(row-1,column-1) == false){if(gameOfLife[row-1][column-1] == 1){liveNeighbours++;}} + if(outOfBound(row,column+1) == false){if(gameOfLife[row][column+1] == 1){liveNeighbours++;}} + if(outOfBound(row,column-1) == false){if(gameOfLife[row][column-1] == 1){liveNeighbours++;}} + // Any dead cell with exactly three live neighbours becomes a live cell, as if by reproduction. + if(liveNeighbours==3){updatedGame[row][column]=1;} + // Remain dead + else {updatedGame[row][column]=0;} +} + +// Run a generation +void tick(){ + // Run generation + for(int i=0;i Date: Thu, 7 Mar 2024 13:17:12 +0100 Subject: [PATCH 08/11] Added author --- src/Boletin_4/Ejercicio_08.c | 2 ++ src/Boletin_4/Ejercicio_11.c | 2 ++ src/Boletin_4/Ejercicio_27.c | 2 ++ src/Boletin_4/Ejercicio_28.c | 2 ++ src/Boletin_4/Ejercicio_36.c | 2 ++ src/Boletin_4/Ejercicio_37.c | 2 ++ src/Boletin_4/Ejercicio_40.c | 2 ++ 7 files changed, 14 insertions(+) diff --git a/src/Boletin_4/Ejercicio_08.c b/src/Boletin_4/Ejercicio_08.c index f48db32..036fe08 100644 --- a/src/Boletin_4/Ejercicio_08.c +++ b/src/Boletin_4/Ejercicio_08.c @@ -1,3 +1,5 @@ +// SPDX-FileCopyrightText: 2024 Sprinter05 +// // SPDX-License-Identifier: GPL-3.0-only #include #define N 10 diff --git a/src/Boletin_4/Ejercicio_11.c b/src/Boletin_4/Ejercicio_11.c index e34aa6a..d2b590a 100644 --- a/src/Boletin_4/Ejercicio_11.c +++ b/src/Boletin_4/Ejercicio_11.c @@ -1,3 +1,5 @@ +// SPDX-FileCopyrightText: 2024 Sprinter05 +// // SPDX-License-Identifier: GPL-3.0-only #include diff --git a/src/Boletin_4/Ejercicio_27.c b/src/Boletin_4/Ejercicio_27.c index b073a59..134fd9e 100644 --- a/src/Boletin_4/Ejercicio_27.c +++ b/src/Boletin_4/Ejercicio_27.c @@ -1,3 +1,5 @@ +// SPDX-FileCopyrightText: 2024 Sprinter05 +// // SPDX-License-Identifier: GPL-3.0-only #include #define N 100 diff --git a/src/Boletin_4/Ejercicio_28.c b/src/Boletin_4/Ejercicio_28.c index 7c70500..d172f91 100644 --- a/src/Boletin_4/Ejercicio_28.c +++ b/src/Boletin_4/Ejercicio_28.c @@ -1,3 +1,5 @@ +// SPDX-FileCopyrightText: 2024 Sprinter05 +// // SPDX-License-Identifier: GPL-3.0-only #include #define N 256 diff --git a/src/Boletin_4/Ejercicio_36.c b/src/Boletin_4/Ejercicio_36.c index fd378d9..68104e6 100644 --- a/src/Boletin_4/Ejercicio_36.c +++ b/src/Boletin_4/Ejercicio_36.c @@ -1,3 +1,5 @@ +// SPDX-FileCopyrightText: 2024 Sprinter05 +// // SPDX-License-Identifier: GPL-3.0-only #include #include diff --git a/src/Boletin_4/Ejercicio_37.c b/src/Boletin_4/Ejercicio_37.c index 31275c9..34c627a 100644 --- a/src/Boletin_4/Ejercicio_37.c +++ b/src/Boletin_4/Ejercicio_37.c @@ -1,3 +1,5 @@ +// SPDX-FileCopyrightText: 2024 Sprinter05 +// // SPDX-License-Identifier: GPL-3.0-only #include #define N 11 diff --git a/src/Boletin_4/Ejercicio_40.c b/src/Boletin_4/Ejercicio_40.c index 2fabec5..ca7fd6d 100644 --- a/src/Boletin_4/Ejercicio_40.c +++ b/src/Boletin_4/Ejercicio_40.c @@ -1,3 +1,5 @@ +// SPDX-FileCopyrightText: 2024 Sprinter05 +// // SPDX-License-Identifier: GPL-3.0-only #include // Main library #include // For managing the program From b014427403675aeab03c6902daa97af2896844c5 Mon Sep 17 00:00:00 2001 From: Sprinter05 Date: Thu, 7 Mar 2024 13:19:23 +0100 Subject: [PATCH 09/11] Fixed Cmake --- src/Boletin_4/CMakeLists.txt | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Boletin_4/CMakeLists.txt b/src/Boletin_4/CMakeLists.txt index c78543b..3c768f9 100644 --- a/src/Boletin_4/CMakeLists.txt +++ b/src/Boletin_4/CMakeLists.txt @@ -14,10 +14,10 @@ add_executable(Bol4-Ej04 Ejercicio_04.c) # add_executable(Bol4-Ej05 Ejercicio_05.c) # add_executable(Bol4-Ej06 Ejercicio_06.c) # add_executable(Bol4-Ej07 Ejercicio_07.c) -# add_executable(Bol4-Ej08 Ejercicio_08.c) +add_executable(Bol4-Ej08 Ejercicio_08.c) add_executable(Bol4-Ej09 Ejercicio_09.c) add_executable(Bol4-Ej10 Ejercicio_10.c) -# add_executable(Bol4-Ej11 Ejercicio_11.c) +add_executable(Bol4-Ej11 Ejercicio_11.c) #add_executable(Bol4-Ej12 Ejercicio_12.c) #add_executable(Bol4-Ej13 Ejercicio_13.c) # add_executable(Bol4-Ej14 Ejercicio_14.c) @@ -33,8 +33,8 @@ add_executable(Bol4-Ej20 Ejercicio_20.c) add_executable(Bol4-Ej24 Ejercicio_24.c) add_executable(Bol4-Ej25 Ejercicio_25.c) # add_executable(Bol4-Ej26 Ejercicio_26.c) -# add_executable(Bol4-Ej27 Ejercicio_27.c) -# add_executable(Bol4-Ej28 Ejercicio_28.c) +add_executable(Bol4-Ej27 Ejercicio_27.c) +add_executable(Bol4-Ej28 Ejercicio_28.c) add_executable(Bol4-Ej29 Ejercicio_29.c) # add_executable(Bol4-Ej30 Ejercicio_30.c) # add_executable(Bol4-Ej31 Ejercicio_31.c) @@ -42,8 +42,8 @@ add_executable(Bol4-Ej29 Ejercicio_29.c) # add_executable(Bol4-Ej33 Ejercicio_33.c) # add_executable(Bol4-Ej34 Ejercicio_34.c) # add_executable(Bol4-Ej35 Ejercicio_35.c) -# add_executable(Bol4-Ej36 Ejercicio_36.c) -# add_executable(Bol4-Ej37 Ejercicio_37.c) +add_executable(Bol4-Ej36 Ejercicio_36.c) +add_executable(Bol4-Ej37 Ejercicio_37.c) # add_executable(Bol4-Ej38 Ejercicio_38.c) # add_executable(Bol4-Ej39 Ejercicio_39.c) -# add_executable(Bol4-Ej40 Ejercicio_40.c) +add_executable(Bol4-Ej40 Ejercicio_40.c) From a7c73e114b698e42c1a7a4349299b7c2985e66be Mon Sep 17 00:00:00 2001 From: Sprinter05 Date: Thu, 7 Mar 2024 13:23:04 +0100 Subject: [PATCH 10/11] Added docs code --- docs/code/Boletin_4/Ejercicio_08.c | 40 ++++++ docs/code/Boletin_4/Ejercicio_11.c | 32 +++++ docs/code/Boletin_4/Ejercicio_27.c | 50 ++++++++ docs/code/Boletin_4/Ejercicio_28.c | 33 +++++ docs/code/Boletin_4/Ejercicio_36.c | 50 ++++++++ docs/code/Boletin_4/Ejercicio_37.c | 51 ++++++++ docs/code/Boletin_4/Ejercicio_40.c | 187 +++++++++++++++++++++++++++++ 7 files changed, 443 insertions(+) create mode 100644 docs/code/Boletin_4/Ejercicio_08.c create mode 100644 docs/code/Boletin_4/Ejercicio_11.c create mode 100644 docs/code/Boletin_4/Ejercicio_27.c create mode 100644 docs/code/Boletin_4/Ejercicio_28.c create mode 100644 docs/code/Boletin_4/Ejercicio_36.c create mode 100644 docs/code/Boletin_4/Ejercicio_37.c create mode 100644 docs/code/Boletin_4/Ejercicio_40.c diff --git a/docs/code/Boletin_4/Ejercicio_08.c b/docs/code/Boletin_4/Ejercicio_08.c new file mode 100644 index 0000000..036fe08 --- /dev/null +++ b/docs/code/Boletin_4/Ejercicio_08.c @@ -0,0 +1,40 @@ +// SPDX-FileCopyrightText: 2024 Sprinter05 +// +// SPDX-License-Identifier: GPL-3.0-only +#include +#define N 10 + +/*Design and implement a program in C language, by sequential search allow +finding the lowest and the highest index were a given X can be found into an +array of integers. The program should allow the user to properly enter the array +of integers and ask for the value you want to find.*/ + +int main(){ + // Define variables and ask for parameters + int nums[N], guess, lGuess, uGuess; + printf("\nInput an array of 10 elements by pressing Enter after each element: "); + for(int i=0; i<10; i++){ + scanf("%d", &nums[i]); + } + // Input guess + printf("\nWhat number do you want to find?: "); + scanf("%d", &guess); + // Lower bound + for(int i=0; i=0; i--){ + if(nums[i] == guess){ + uGuess = i; + break; + } + } + // Print solutions + printf("\nLower bound solution: %d", lGuess); + printf("\nUpper bound solution: %d", uGuess); + printf("\n"); +} \ No newline at end of file diff --git a/docs/code/Boletin_4/Ejercicio_11.c b/docs/code/Boletin_4/Ejercicio_11.c new file mode 100644 index 0000000..d2b590a --- /dev/null +++ b/docs/code/Boletin_4/Ejercicio_11.c @@ -0,0 +1,32 @@ +// SPDX-FileCopyrightText: 2024 Sprinter05 +// +// SPDX-License-Identifier: GPL-3.0-only +#include + +/*Design and implement a recursive function in C language that returns +the sum of the elements of an array of integers.*/ + +// Sum all the elements of the array using recursion +int arraySum(int n, int sumNums[n], int loops, int accum){ + if (loops == 0){return accum;} else{ + accum+=sumNums[n-loops]; + loops--; + arraySum(n, sumNums, loops, accum); + } +} + +int main(){ + // Define variables and ask for parameters + int n = 10; + int toSum[n], accum = 0, loops = n; + int result; + printf("Input the 10 numbers for the array separated by Enter:\n"); + for(int i=0; i<10; i++){ + scanf("%d", &toSum[i]); + } + // Recursion fun starts here + result = arraySum(n, toSum, loops, accum); + // Print result + printf("\nThe result of the sum is %d\n", result); + return 0; +} \ No newline at end of file diff --git a/docs/code/Boletin_4/Ejercicio_27.c b/docs/code/Boletin_4/Ejercicio_27.c new file mode 100644 index 0000000..134fd9e --- /dev/null +++ b/docs/code/Boletin_4/Ejercicio_27.c @@ -0,0 +1,50 @@ +// SPDX-FileCopyrightText: 2024 Sprinter05 +// +// SPDX-License-Identifier: GPL-3.0-only +#include +#define N 100 + +/*Design and implement a program in C language to read a sentence +(maximum 100 characters) and then showing every word of it followed +by the number of letters that compose it. For simplicity, assume that +the words can be separated only by spaces, commas or periods.*/ + +// Count the amount of characters in the string +void countString(char toCount[N]){ + int count = 0; + for(int i=0; toCount[i]!='\0'; i++){ + count++; + } + printf("Word %s has %d characters\n", toCount, count); +} + +// Separate the string and fix multiple separators in the string by ignoring them +void separateString(char toSplit[N]){ + char splitted[N][N]; + int count=0, row=0, column=0; + while(toSplit[count] != '\n'){ + if(toSplit[count] == ' ' || toSplit[count] == ',' || toSplit[count] == '.'){ + splitted[row][column] = '\0'; + column = 0; + if (toSplit[count-1] != ' ' && toSplit[count-1] != ',' && toSplit[count-1] != '.'){row++;} + } else { + splitted[row][column] = toSplit[count]; + column++; + } + count++; + } + for(int i=0; splitted[i][0] != '\0'; i++){ + countString(splitted[i]); + } +} + +int main(){ + // Define variables and ask for parameters + char sentence[N]; + printf("Type a sentence of max 100 characters:\n"); + // fgets instead of gets for buffer overflow protection + fgets(sentence, N, stdin); + // Start the fun + separateString(sentence); + return 0; +} \ No newline at end of file diff --git a/docs/code/Boletin_4/Ejercicio_28.c b/docs/code/Boletin_4/Ejercicio_28.c new file mode 100644 index 0000000..d172f91 --- /dev/null +++ b/docs/code/Boletin_4/Ejercicio_28.c @@ -0,0 +1,33 @@ +// SPDX-FileCopyrightText: 2024 Sprinter05 +// +// SPDX-License-Identifier: GPL-3.0-only +#include +#define N 256 + +/*Design and implement a program in C language to read a phrase (sequence of +characters to end of line), replace all sequences of two or more spaces with +a single space and the show the modified phrase.*/ + +int main(){ + // Define variables and ask for parameters + int i=0, j=0; + char sentence[N], fixedSentence[N]; + printf("Type a sentence\n"); + // fgets instead of gets for buffer protection + fgets(sentence, N, stdin); + // Fix the sentence's multiple spaces + while(sentence[i]!='\0'){ + if(sentence[i] == ' ' && sentence[i+1] == ' '){ + i++; + continue; + } else { + fixedSentence[j]=sentence[i]; + i++; + j++; + } + } + // Print the result after apprending the end of string to the fixed variable + fixedSentence[j+1] = '\0'; + printf("\nThe sentence with fixed spaces is:\n%s", fixedSentence); + return 0; +} \ No newline at end of file diff --git a/docs/code/Boletin_4/Ejercicio_36.c b/docs/code/Boletin_4/Ejercicio_36.c new file mode 100644 index 0000000..68104e6 --- /dev/null +++ b/docs/code/Boletin_4/Ejercicio_36.c @@ -0,0 +1,50 @@ +// SPDX-FileCopyrightText: 2024 Sprinter05 +// +// SPDX-License-Identifier: GPL-3.0-only +#include +#include +#define N 100 + +/*Implement a program that ask for five integers (ni > 0) and display each number and +factorial decomposition. Use a suitable data structure to store both the numbers +and decompositions.*/ + +void factorialDecomp(int toDecomp){ + int factors[N], primes=2, loops=0, og=toDecomp; + // Check if its 1 or 0 and just print out that the decomp is 1 + if(toDecomp == 0 | toDecomp == 1){ + printf("\nNumber %d factorial decomposition is: 1", og); + return; + } + // Repeat the factorization with each reduced number until its 0 + for(int i=0;i +#define N 11 +#define M 100 + +/*Implement a program that reads a date and store it in a string that +fit your 10 characters (dd/mm/yyyy) adding zeros to the left of the day, +month and year if needed, and calculate and store in memory the next 100 leap years. +The program should give the user the option to change the date entered and +see on the screen the n leap years from the given date.*/ + +void checkLeaps(int n, int year){ + int closeLeap, leaps[M], counter=1; + //Check closest + for(int i=0;i<4;i++){ + if((year+i)%4 == 0){ + closeLeap = year+i; + break; + } + } + // Get all the following leap years until the max amount is satisfied + leaps[0]=closeLeap; + while(counter != 100){ + leaps[counter]=closeLeap+(4*counter); + counter++; + } + // Print results + printf("\nFollowing 100 leap years:\n"); + for(int i=0; i // Main library +#include // For managing the program +#include // Bool function +#include // Use UNIX commands +#include // For random numbers +#define N 16 // Change this number to change the matrix size +#define SPEED 2 // Higher means faster: MUST BE GREATER OR EQUAL THAN 1 +#define clear() printf("\033[H\033[J") // Clean screen + +/*Design and implement a program in C language to simulate the game of life of John Conway.*/ + +// NOTE: RUN FROM VSCODE TERMINAL OR THE MODERN WINDOWS TERMINAL APP NOT CMD OTHERWISE UTF-8 EMOJIS WILL NOT DISPLAY +// ALSO MAKE SURE UTF-8 SUPPORT IS ENABLED IN YOUR TERMINAL OF CHOICE, APPLIES TO ALL OPERATING SYSTEMS + +int gameOfLife[N][N]; +int updatedGame[N][N]; +int ticks=0; // Generations + +// THIS IS THE MATRIX THAT WILL RUN IF THE OPTION c (choose) IS CHOSEN AT RUNTIME +// THIS EXAMPLE MATRIX IS OF SIZE 16X16 SO IF YOU CHANGE N MODIFY THE SIZE HERE TOO +// 0 = DISABLED, 1 = ENABLED +int chooseGameOfLife[N][N] = { + {1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, + {1,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0}, + {0,0,1,1,0,0,0,1,0,0,1,0,0,0,0,0}, + {0,0,1,1,0,0,0,1,0,0,1,0,0,0,0,0}, + {0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0}, + {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, + {0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0}, + {0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0}, + {0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0}, + {0,0,0,1,1,1,1,0,0,0,0,0,0,0,0,0}, + {0,0,1,0,0,0,1,0,0,0,0,0,0,0,0,0}, + {0,0,0,0,0,0,1,0,0,0,1,1,0,0,0,0}, + {0,0,1,0,0,1,0,0,0,0,1,0,1,0,0,0}, + {0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0}, + {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, + {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0} +}; + +// Make sure the cell is not outsided of the matrix +bool outOfBound(int row, int column){ + bool oob; + if(row >= N || row < 0 || column >= N || column < 0){oob = true;} + else {oob = false;} + return oob; +} + +// Check rules 1, 2 and 3 for death status +void checkDeath(int row, int column){ + int liveNeighbours=0; + // Check neighbours + if(outOfBound(row+1,column) == false){if(gameOfLife[row+1][column] == 1){liveNeighbours++;}} + if(outOfBound(row+1,column+1) == false){if(gameOfLife[row+1][column+1] == 1){liveNeighbours++;}} + if(outOfBound(row+1,column-1) == false){if(gameOfLife[row+1][column-1] == 1){liveNeighbours++;}} + if(outOfBound(row-1,column) == false){if(gameOfLife[row-1][column] == 1){liveNeighbours++;}} + if(outOfBound(row-1,column+1) == false){if(gameOfLife[row-1][column+1] == 1){liveNeighbours++;}} + if(outOfBound(row-1,column-1) == false){if(gameOfLife[row-1][column-1] == 1){liveNeighbours++;}} + if(outOfBound(row,column+1) == false){if(gameOfLife[row][column+1] == 1){liveNeighbours++;}} + if(outOfBound(row,column-1) == false){if(gameOfLife[row][column-1] == 1){liveNeighbours++;}} + // Any live cell with fewer than two live neighbours dies, as if by underpopulation. + if(liveNeighbours<2){updatedGame[row][column]=0;} + // Any live cell with two or three live neighbours lives on to the next generation. + else if(liveNeighbours>=2 && liveNeighbours<=3){updatedGame[row][column]=1;} + // Any live cell with more than three live neighbours dies, as if by overpopulation. + else if(liveNeighbours>3){updatedGame[row][column]=0;} +} + +// Check rule 4 for revive status +void checkRevive(int row, int column){ + int liveNeighbours=0; + // Check neighbours + if(outOfBound(row+1,column) == false){if(gameOfLife[row+1][column] == 1){liveNeighbours++;}} + if(outOfBound(row+1,column+1) == false){if(gameOfLife[row+1][column+1] == 1){liveNeighbours++;}} + if(outOfBound(row+1,column-1) == false){if(gameOfLife[row+1][column-1] == 1){liveNeighbours++;}} + if(outOfBound(row-1,column) == false){if(gameOfLife[row-1][column] == 1){liveNeighbours++;}} + if(outOfBound(row-1,column+1) == false){if(gameOfLife[row-1][column+1] == 1){liveNeighbours++;}} + if(outOfBound(row-1,column-1) == false){if(gameOfLife[row-1][column-1] == 1){liveNeighbours++;}} + if(outOfBound(row,column+1) == false){if(gameOfLife[row][column+1] == 1){liveNeighbours++;}} + if(outOfBound(row,column-1) == false){if(gameOfLife[row][column-1] == 1){liveNeighbours++;}} + // Any dead cell with exactly three live neighbours becomes a live cell, as if by reproduction. + if(liveNeighbours==3){updatedGame[row][column]=1;} + // Remain dead + else {updatedGame[row][column]=0;} +} + +// Run a generation +void tick(){ + // Run generation + for(int i=0;i Date: Thu, 7 Mar 2024 18:42:13 +0100 Subject: [PATCH 11/11] =?UTF-8?q?A=C3=B1adida=20linea=20entre=20Licencia-C?= =?UTF-8?q?odigo=20y=20eliminado=20enunciados?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/code/Boletin_4/Ejercicio_08.c | 7 ++----- docs/code/Boletin_4/Ejercicio_11.c | 5 ++--- docs/code/Boletin_4/Ejercicio_27.c | 7 ++----- docs/code/Boletin_4/Ejercicio_28.c | 6 ++---- docs/code/Boletin_4/Ejercicio_36.c | 6 ++---- docs/code/Boletin_4/Ejercicio_37.c | 8 ++------ docs/code/Boletin_4/Ejercicio_40.c | 4 ++-- src/Boletin_4/Ejercicio_08.c | 7 ++----- src/Boletin_4/Ejercicio_11.c | 5 ++--- src/Boletin_4/Ejercicio_27.c | 7 ++----- src/Boletin_4/Ejercicio_28.c | 6 ++---- src/Boletin_4/Ejercicio_36.c | 6 ++---- src/Boletin_4/Ejercicio_37.c | 8 ++------ src/Boletin_4/Ejercicio_40.c | 4 ++-- 14 files changed, 28 insertions(+), 58 deletions(-) diff --git a/docs/code/Boletin_4/Ejercicio_08.c b/docs/code/Boletin_4/Ejercicio_08.c index 036fe08..56d7631 100644 --- a/docs/code/Boletin_4/Ejercicio_08.c +++ b/docs/code/Boletin_4/Ejercicio_08.c @@ -1,14 +1,11 @@ // SPDX-FileCopyrightText: 2024 Sprinter05 // // SPDX-License-Identifier: GPL-3.0-only + +// Libraries #include #define N 10 -/*Design and implement a program in C language, by sequential search allow -finding the lowest and the highest index were a given X can be found into an -array of integers. The program should allow the user to properly enter the array -of integers and ask for the value you want to find.*/ - int main(){ // Define variables and ask for parameters int nums[N], guess, lGuess, uGuess; diff --git a/docs/code/Boletin_4/Ejercicio_11.c b/docs/code/Boletin_4/Ejercicio_11.c index d2b590a..b1c4770 100644 --- a/docs/code/Boletin_4/Ejercicio_11.c +++ b/docs/code/Boletin_4/Ejercicio_11.c @@ -1,10 +1,9 @@ // SPDX-FileCopyrightText: 2024 Sprinter05 // // SPDX-License-Identifier: GPL-3.0-only -#include -/*Design and implement a recursive function in C language that returns -the sum of the elements of an array of integers.*/ +// Libraries +#include // Sum all the elements of the array using recursion int arraySum(int n, int sumNums[n], int loops, int accum){ diff --git a/docs/code/Boletin_4/Ejercicio_27.c b/docs/code/Boletin_4/Ejercicio_27.c index 134fd9e..8b53f23 100644 --- a/docs/code/Boletin_4/Ejercicio_27.c +++ b/docs/code/Boletin_4/Ejercicio_27.c @@ -1,14 +1,11 @@ // SPDX-FileCopyrightText: 2024 Sprinter05 // // SPDX-License-Identifier: GPL-3.0-only + +// Libraries #include #define N 100 -/*Design and implement a program in C language to read a sentence -(maximum 100 characters) and then showing every word of it followed -by the number of letters that compose it. For simplicity, assume that -the words can be separated only by spaces, commas or periods.*/ - // Count the amount of characters in the string void countString(char toCount[N]){ int count = 0; diff --git a/docs/code/Boletin_4/Ejercicio_28.c b/docs/code/Boletin_4/Ejercicio_28.c index d172f91..32c3299 100644 --- a/docs/code/Boletin_4/Ejercicio_28.c +++ b/docs/code/Boletin_4/Ejercicio_28.c @@ -1,13 +1,11 @@ // SPDX-FileCopyrightText: 2024 Sprinter05 // // SPDX-License-Identifier: GPL-3.0-only + +// Libraries #include #define N 256 -/*Design and implement a program in C language to read a phrase (sequence of -characters to end of line), replace all sequences of two or more spaces with -a single space and the show the modified phrase.*/ - int main(){ // Define variables and ask for parameters int i=0, j=0; diff --git a/docs/code/Boletin_4/Ejercicio_36.c b/docs/code/Boletin_4/Ejercicio_36.c index 68104e6..74c3b32 100644 --- a/docs/code/Boletin_4/Ejercicio_36.c +++ b/docs/code/Boletin_4/Ejercicio_36.c @@ -1,14 +1,12 @@ // SPDX-FileCopyrightText: 2024 Sprinter05 // // SPDX-License-Identifier: GPL-3.0-only + +// Libraries #include #include #define N 100 -/*Implement a program that ask for five integers (ni > 0) and display each number and -factorial decomposition. Use a suitable data structure to store both the numbers -and decompositions.*/ - void factorialDecomp(int toDecomp){ int factors[N], primes=2, loops=0, og=toDecomp; // Check if its 1 or 0 and just print out that the decomp is 1 diff --git a/docs/code/Boletin_4/Ejercicio_37.c b/docs/code/Boletin_4/Ejercicio_37.c index 34c627a..89dc693 100644 --- a/docs/code/Boletin_4/Ejercicio_37.c +++ b/docs/code/Boletin_4/Ejercicio_37.c @@ -1,16 +1,12 @@ // SPDX-FileCopyrightText: 2024 Sprinter05 // // SPDX-License-Identifier: GPL-3.0-only + +// Libraries #include #define N 11 #define M 100 -/*Implement a program that reads a date and store it in a string that -fit your 10 characters (dd/mm/yyyy) adding zeros to the left of the day, -month and year if needed, and calculate and store in memory the next 100 leap years. -The program should give the user the option to change the date entered and -see on the screen the n leap years from the given date.*/ - void checkLeaps(int n, int year){ int closeLeap, leaps[M], counter=1; //Check closest diff --git a/docs/code/Boletin_4/Ejercicio_40.c b/docs/code/Boletin_4/Ejercicio_40.c index ca7fd6d..f49bc08 100644 --- a/docs/code/Boletin_4/Ejercicio_40.c +++ b/docs/code/Boletin_4/Ejercicio_40.c @@ -1,6 +1,8 @@ // SPDX-FileCopyrightText: 2024 Sprinter05 // // SPDX-License-Identifier: GPL-3.0-only + +// Libraries #include // Main library #include // For managing the program #include // Bool function @@ -10,8 +12,6 @@ #define SPEED 2 // Higher means faster: MUST BE GREATER OR EQUAL THAN 1 #define clear() printf("\033[H\033[J") // Clean screen -/*Design and implement a program in C language to simulate the game of life of John Conway.*/ - // NOTE: RUN FROM VSCODE TERMINAL OR THE MODERN WINDOWS TERMINAL APP NOT CMD OTHERWISE UTF-8 EMOJIS WILL NOT DISPLAY // ALSO MAKE SURE UTF-8 SUPPORT IS ENABLED IN YOUR TERMINAL OF CHOICE, APPLIES TO ALL OPERATING SYSTEMS diff --git a/src/Boletin_4/Ejercicio_08.c b/src/Boletin_4/Ejercicio_08.c index 036fe08..56d7631 100644 --- a/src/Boletin_4/Ejercicio_08.c +++ b/src/Boletin_4/Ejercicio_08.c @@ -1,14 +1,11 @@ // SPDX-FileCopyrightText: 2024 Sprinter05 // // SPDX-License-Identifier: GPL-3.0-only + +// Libraries #include #define N 10 -/*Design and implement a program in C language, by sequential search allow -finding the lowest and the highest index were a given X can be found into an -array of integers. The program should allow the user to properly enter the array -of integers and ask for the value you want to find.*/ - int main(){ // Define variables and ask for parameters int nums[N], guess, lGuess, uGuess; diff --git a/src/Boletin_4/Ejercicio_11.c b/src/Boletin_4/Ejercicio_11.c index d2b590a..b1c4770 100644 --- a/src/Boletin_4/Ejercicio_11.c +++ b/src/Boletin_4/Ejercicio_11.c @@ -1,10 +1,9 @@ // SPDX-FileCopyrightText: 2024 Sprinter05 // // SPDX-License-Identifier: GPL-3.0-only -#include -/*Design and implement a recursive function in C language that returns -the sum of the elements of an array of integers.*/ +// Libraries +#include // Sum all the elements of the array using recursion int arraySum(int n, int sumNums[n], int loops, int accum){ diff --git a/src/Boletin_4/Ejercicio_27.c b/src/Boletin_4/Ejercicio_27.c index 134fd9e..8b53f23 100644 --- a/src/Boletin_4/Ejercicio_27.c +++ b/src/Boletin_4/Ejercicio_27.c @@ -1,14 +1,11 @@ // SPDX-FileCopyrightText: 2024 Sprinter05 // // SPDX-License-Identifier: GPL-3.0-only + +// Libraries #include #define N 100 -/*Design and implement a program in C language to read a sentence -(maximum 100 characters) and then showing every word of it followed -by the number of letters that compose it. For simplicity, assume that -the words can be separated only by spaces, commas or periods.*/ - // Count the amount of characters in the string void countString(char toCount[N]){ int count = 0; diff --git a/src/Boletin_4/Ejercicio_28.c b/src/Boletin_4/Ejercicio_28.c index d172f91..32c3299 100644 --- a/src/Boletin_4/Ejercicio_28.c +++ b/src/Boletin_4/Ejercicio_28.c @@ -1,13 +1,11 @@ // SPDX-FileCopyrightText: 2024 Sprinter05 // // SPDX-License-Identifier: GPL-3.0-only + +// Libraries #include #define N 256 -/*Design and implement a program in C language to read a phrase (sequence of -characters to end of line), replace all sequences of two or more spaces with -a single space and the show the modified phrase.*/ - int main(){ // Define variables and ask for parameters int i=0, j=0; diff --git a/src/Boletin_4/Ejercicio_36.c b/src/Boletin_4/Ejercicio_36.c index 68104e6..74c3b32 100644 --- a/src/Boletin_4/Ejercicio_36.c +++ b/src/Boletin_4/Ejercicio_36.c @@ -1,14 +1,12 @@ // SPDX-FileCopyrightText: 2024 Sprinter05 // // SPDX-License-Identifier: GPL-3.0-only + +// Libraries #include #include #define N 100 -/*Implement a program that ask for five integers (ni > 0) and display each number and -factorial decomposition. Use a suitable data structure to store both the numbers -and decompositions.*/ - void factorialDecomp(int toDecomp){ int factors[N], primes=2, loops=0, og=toDecomp; // Check if its 1 or 0 and just print out that the decomp is 1 diff --git a/src/Boletin_4/Ejercicio_37.c b/src/Boletin_4/Ejercicio_37.c index 34c627a..89dc693 100644 --- a/src/Boletin_4/Ejercicio_37.c +++ b/src/Boletin_4/Ejercicio_37.c @@ -1,16 +1,12 @@ // SPDX-FileCopyrightText: 2024 Sprinter05 // // SPDX-License-Identifier: GPL-3.0-only + +// Libraries #include #define N 11 #define M 100 -/*Implement a program that reads a date and store it in a string that -fit your 10 characters (dd/mm/yyyy) adding zeros to the left of the day, -month and year if needed, and calculate and store in memory the next 100 leap years. -The program should give the user the option to change the date entered and -see on the screen the n leap years from the given date.*/ - void checkLeaps(int n, int year){ int closeLeap, leaps[M], counter=1; //Check closest diff --git a/src/Boletin_4/Ejercicio_40.c b/src/Boletin_4/Ejercicio_40.c index ca7fd6d..f49bc08 100644 --- a/src/Boletin_4/Ejercicio_40.c +++ b/src/Boletin_4/Ejercicio_40.c @@ -1,6 +1,8 @@ // SPDX-FileCopyrightText: 2024 Sprinter05 // // SPDX-License-Identifier: GPL-3.0-only + +// Libraries #include // Main library #include // For managing the program #include // Bool function @@ -10,8 +12,6 @@ #define SPEED 2 // Higher means faster: MUST BE GREATER OR EQUAL THAN 1 #define clear() printf("\033[H\033[J") // Clean screen -/*Design and implement a program in C language to simulate the game of life of John Conway.*/ - // NOTE: RUN FROM VSCODE TERMINAL OR THE MODERN WINDOWS TERMINAL APP NOT CMD OTHERWISE UTF-8 EMOJIS WILL NOT DISPLAY // ALSO MAKE SURE UTF-8 SUPPORT IS ENABLED IN YOUR TERMINAL OF CHOICE, APPLIES TO ALL OPERATING SYSTEMS