uni

University stuff
git clone git://git.christosmarg.xyz/uni-assignments.git
Log | Files | Refs | README | LICENSE

commit 301cc5f9e579c50b3f5f5cd94ee720969ce88539
parent 91f6f902152890d796bb393982482b21f26e42b9
Author: Christos Margiolis <christos@margiolis.net>
Date:   Sun, 19 Jan 2020 22:17:18 +0200

progress on c/f/kombinations

Diffstat:
Aassignment-1.5-arrays-pointers-files/combinations/bin/combs | 0
Massignment-1.5-arrays-pointers-files/combinations/include/arrhandler.h | 14--------------
Dassignment-1.5-arrays-pointers-files/combinations/include/ccolors.h | 32--------------------------------
Massignment-1.5-arrays-pointers-files/combinations/include/combinations.h | 18+++++++++++++-----
Aassignment-1.5-arrays-pointers-files/combinations/obj/arrhandler.o | 0
Aassignment-1.5-arrays-pointers-files/combinations/obj/combinations.o | 0
Aassignment-1.5-arrays-pointers-files/combinations/obj/main.o | 0
Massignment-1.5-arrays-pointers-files/combinations/src/arrhandler.c | 89++++---------------------------------------------------------------------------
Massignment-1.5-arrays-pointers-files/combinations/src/combinations.c | 115+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------------
Massignment-1.5-arrays-pointers-files/combinations/src/main.c | 10+++-------
Massignment-1.5-arrays-pointers-files/combinations/txt/data.txt | 50+++++++++++---------------------------------------
Aassignment-1.5-arrays-pointers-files/combinations/txt/data40.txt | 48++++++++++++++++++++++++++++++++++++++++++++++++
Aassignment-1.5-arrays-pointers-files/combinations/txt/data49.txt | 55+++++++++++++++++++++++++++++++++++++++++++++++++++++++
Massignment-1.5-arrays-pointers-files/documentation/assignment-1.5.pdf | 0
Massignment-1.5-arrays-pointers-files/documentation/assignment-1.5.synctex.gz | 0
Massignment-1.5-arrays-pointers-files/documentation/assignment-1.5.tex | 44+++++++++++++++++++++++++++++++++++---------
Aassignment-1.5-arrays-pointers-files/fcombinations/bin/fcombs | 0
Massignment-1.5-arrays-pointers-files/fcombinations/include/arrhandler.h | 14--------------
Dassignment-1.5-arrays-pointers-files/fcombinations/include/ccolors.h | 32--------------------------------
Massignment-1.5-arrays-pointers-files/fcombinations/include/fcombinations.h | 31+++++++++++--------------------
Aassignment-1.5-arrays-pointers-files/fcombinations/obj/arrhandler.o | 0
Aassignment-1.5-arrays-pointers-files/fcombinations/obj/fcombinations.o | 0
Aassignment-1.5-arrays-pointers-files/fcombinations/obj/main.o | 0
Massignment-1.5-arrays-pointers-files/fcombinations/src/arrhandler.c | 88+++----------------------------------------------------------------------------
Massignment-1.5-arrays-pointers-files/fcombinations/src/fcombinations.c | 98+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------------
Massignment-1.5-arrays-pointers-files/fcombinations/txt/data.txt | 18++++++++++++++++++
Aassignment-1.5-arrays-pointers-files/fcombinations/txt/data40.txt | 48++++++++++++++++++++++++++++++++++++++++++++++++
Aassignment-1.5-arrays-pointers-files/fcombinations/txt/data49.txt | 55+++++++++++++++++++++++++++++++++++++++++++++++++++++++
Aassignment-1.5-arrays-pointers-files/kcombinations/Makefile | 37+++++++++++++++++++++++++++++++++++++
Aassignment-1.5-arrays-pointers-files/kcombinations/bin/combs | 0
Aassignment-1.5-arrays-pointers-files/kcombinations/include/arrhandler.h | 14++++++++++++++
Aassignment-1.5-arrays-pointers-files/kcombinations/include/kcombinations.h | 21+++++++++++++++++++++
Aassignment-1.5-arrays-pointers-files/kcombinations/obj/arrhandler.o | 0
Aassignment-1.5-arrays-pointers-files/kcombinations/obj/kcombinations.o | 0
Aassignment-1.5-arrays-pointers-files/kcombinations/obj/main.o | 0
Aassignment-1.5-arrays-pointers-files/kcombinations/src/arrhandler.c | 80+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Aassignment-1.5-arrays-pointers-files/kcombinations/src/kcombinations.c | 160+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Aassignment-1.5-arrays-pointers-files/kcombinations/src/main.c | 24++++++++++++++++++++++++
Aassignment-1.5-arrays-pointers-files/kcombinations/txt/kdata.txt | 17+++++++++++++++++
Aassignment-1.5-arrays-pointers-files/kcombinations/txt/kdata40.txt | 48++++++++++++++++++++++++++++++++++++++++++++++++
Aassignment-1.5-arrays-pointers-files/kcombinations/txt/kdata49.txt | 56++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Cassignment-1.5-arrays-pointers-files/fcombinations/txt/data.txt -> assignment-1.5-arrays-pointers-files/kcombinations/txt/koutput.txt | 0
Aassignment-1.5-arrays-pointers-files/minesweeper/bin/minesweeper | 0
Massignment-1.5-arrays-pointers-files/minesweeper/mnsout.txt | 134++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-------------
Aassignment-1.5-arrays-pointers-files/minesweeper/obj/gameplay.o | 0
Aassignment-1.5-arrays-pointers-files/minesweeper/obj/main.o | 0
Aassignment-1.5-arrays-pointers-files/minesweeper/obj/minesweeper.o | 0
Massignment-1.5-arrays-pointers-files/notes.md | 23++---------------------
48 files changed, 1047 insertions(+), 426 deletions(-)

diff --git a/assignment-1.5-arrays-pointers-files/combinations/bin/combs b/assignment-1.5-arrays-pointers-files/combinations/bin/combs Binary files differ. diff --git a/assignment-1.5-arrays-pointers-files/combinations/include/arrhandler.h b/assignment-1.5-arrays-pointers-files/combinations/include/arrhandler.h @@ -9,19 +9,5 @@ bool exists_in_array(int *, int, int); void quicksort(int *, int, int); int partition(int *, int, int); void swap(int *, int *); -void printarray(int *, int); - -void combinations(int *, int, int, int, int); -int even_calc(int *); -bool belongs_x(int, int, int); -int sum_calc(int *); -bool belongs_y(int, int, int); -int sum_comb_calc(); - -void print(); -int not_printed(); -int not_first_condition(); -int not_second_condition_only(); -int frequency(); #endif \ No newline at end of file diff --git a/assignment-1.5-arrays-pointers-files/combinations/include/ccolors.h b/assignment-1.5-arrays-pointers-files/combinations/include/ccolors.h @@ -1,31 +0,0 @@ -#ifndef C_COLORS_H -#define C_COLORS_H - -#include <stdio.h> - -enum options {RED, GREEN, YELLOW, BLUE, MAGENTA, CYAN, BOLD_RED, BOLD_GREEN, BOLD_YELLOW, BOLD_BLUE, BOLD_MAGENTA, BOLD_CYAN, STANDARD}; -enum options color; - -void set_color(enum options color) -{ - switch (color) - { - case RED: printf("\033[0;31m"); break; - case GREEN: printf("\033[0;32m"); break; - case YELLOW: printf("\033[0;33m"); break; - case BLUE: printf("\033[0;34m"); break; - case MAGENTA: printf("\033[0;35m"); break; - case CYAN: printf("\033[0;36m"); break; - - case BOLD_RED: printf("\033[1;31m"); break; - case BOLD_GREEN: printf("\033[1;32m"); break; - case BOLD_YELLOW: printf("\033[1;33m"); break; - case BOLD_BLUE: printf("\033[1;34m"); break; - case BOLD_MAGENTA: printf("\033[1;35m"); break; - case BOLD_CYAN: printf("\033[1;36m"); break; - - case STANDARD: printf("\033[0m"); break; - } -} - -#endif- \ No newline at end of file diff --git a/assignment-1.5-arrays-pointers-files/combinations/include/combinations.h b/assignment-1.5-arrays-pointers-files/combinations/include/combinations.h @@ -1,14 +1,22 @@ #ifndef COMBINATIONS_H #define COMBINATIONS_H -int get_n(); -int get_k(); +#include <stdbool.h> + +#define COMBSN 6 void x_pair(int *, int *); void y_pair(int *, int *); -void print_combs(int *); -int combinations_count(int); -int factorial(int); +void print_combs(int *, int, int, int, int, int); +void combinations(int *, int *, int, int, int, int *, int *, int *, int, int, int, int); + +bool even_calc(int *, int, int); +bool sum_comb_calc(int *, int, int); + +int frequency(); +long int combinations_count(int); +long double factorial(int); +void print_other(int, int, int, int); // add freq #endif \ No newline at end of file diff --git a/assignment-1.5-arrays-pointers-files/combinations/obj/arrhandler.o b/assignment-1.5-arrays-pointers-files/combinations/obj/arrhandler.o Binary files differ. diff --git a/assignment-1.5-arrays-pointers-files/combinations/obj/combinations.o b/assignment-1.5-arrays-pointers-files/combinations/obj/combinations.o Binary files differ. diff --git a/assignment-1.5-arrays-pointers-files/combinations/obj/main.o b/assignment-1.5-arrays-pointers-files/combinations/obj/main.o Binary files differ. diff --git a/assignment-1.5-arrays-pointers-files/combinations/src/arrhandler.c b/assignment-1.5-arrays-pointers-files/combinations/src/arrhandler.c @@ -1,21 +1,17 @@ +#include <stdio.h> #include <stdlib.h> #include "arrhandler.h" -#include "ccolors.h" - -#define COMBSN 6 +#include "combinations.h" int *fill_array(int N) { - int *arr, num, i = 0; - - arr = (int *)malloc(N * sizeof(int)); + int num, i = 0; + int *arr = (int *)malloc(N * sizeof(int)); if (arr == NULL) { - set_color(BOLD_RED); printf("Error! Not enough memory, exiting...\n"); - set_color(STANDARD); exit(EXIT_FAILURE); } else @@ -80,81 +76,4 @@ void swap(int *a, int *b) int temp = *a; *a = *b; *b = temp; -} - - -void printarray(int *arr, int N) -{ - for (int i = 0; i < N; i++) - printf("arr[%d] = %d\n", i, *(arr + i)); -} - -int even_calc(int *arr) -{ - -} - - -bool belongs_x(int numEven, int x1, int x2) -{ - -} - - -int sum_calc(int *arr) -{ - -} - - -bool belongs_y(int sumNums, int y1, int y2) -{ - -} - - -void print_combs(int *arr) -{ - int i; - - for (i = 0; i < COMBSN; i++) - printf("%d ", *(arr + i)); - printf("\n"); -} - - -void print(int N) -{ - -} - - - -int sum_comb_calc() -{ - -} - - -int not_printed() -{ - -} - - -int not_first_condition() -{ - -} - - -int not_second_condition_only() -{ - -} - - -int frequency() -{ - } \ No newline at end of file diff --git a/assignment-1.5-arrays-pointers-files/combinations/src/combinations.c b/assignment-1.5-arrays-pointers-files/combinations/src/combinations.c @@ -1,10 +1,8 @@ #include <stdio.h> #include <stdlib.h> #include <stdbool.h> -#include <string.h> #include "combinations.h" - -#define COMBSN 6 +#include "arrhandler.h" int get_n() @@ -13,10 +11,13 @@ int get_n() do { + system("clear||cls"); printf("N (6 < N <= 49): "); scanf("%d", &N); } while (N <= 6 || N > 49); + system("clear||cls"); + return N; } @@ -45,32 +46,101 @@ void y_pair(int *y1, int *y2) } -void combinations(int *arr, int x1, int x2, int y1, int y2) +void print_combs(int *arr, int N, int x1, int x2, int y1, int y2) +{ + int *currComb = (int *)malloc(N * sizeof(int)); + int unFrstCond = 0, unScndCondOnly = 0, printed = 0; + + if (currComb == NULL) + { + printf("Error! Not enough memory, exiting...\n"); + exit(EXIT_FAILURE); + } + else + { + combinations(arr, currComb, 0, N-1, 0, &printed, &unFrstCond, &unScndCondOnly, x1, x2, y1, y2); + print_other(N, unFrstCond, unScndCondOnly, printed); + } + + free(currComb); +} + + +void combinations(int *arr, int *currComb, int start, int end, int index, int *printed, int *unFrstCond, int *unScndCondOnly, int x1, int x2, int y1, int y2) { - int i, j, k, l, m, n; - - for (i = 0; i < COMBSN-5; i++) - for (j = i+1; j < COMBSN-4; j++) - for (k = j+1; k < COMBSN-3; k++) - for (l = k+1; l < COMBSN-2; l++) - for (m = l+1; m < COMBSN-1; m++) - for (n = m+1; n < COMBSN; n++) - { - printf("%d %d %d %d %d %d", *(arr + i), *(arr + j), *(arr + k), *(arr + l), *(arr + m), *(arr + n)); - printf("\n"); - } + int i, j; + + if (index == COMBSN) + { + for (j = 0; j < COMBSN; j++) + { + if (even_calc(currComb, x1, x2) && sum_comb_calc(currComb, y1, y2)) + { + printf("%d ", *(currComb + j)); + if (j == COMBSN - 1) { (*printed)++; printf("\n"); } + } // add freq + } + if (!even_calc(currComb, x1, x2) && sum_comb_calc(currComb, y1, y2)) (*unFrstCond)++; + if (!sum_comb_calc(currComb, y1, y2)) (*unScndCondOnly)++; + return; + } + + for (i = start; i <= end && end-i+1 >= COMBSN-index; i++) + { + *(currComb + index) = *(arr + i); + combinations(arr, currComb, i+1, end, index+1, printed, unFrstCond, unScndCondOnly, x1, x2, y1, y2); + } } -int combinations_count(int N) +bool even_calc(int *arr, int x1, int x2) { - return factorial(N) / (factorial(COMBSN) * factorial(N - COMBSN)); + int numEven = 0, i; + + for (i = 0; i < COMBSN; i++) + if (*(arr + i) % 2 == 0) numEven++; + + return (numEven >= x1 && numEven <= x2) ? true : false; +} + + +bool sum_comb_calc(int *arr, int y1, int y2) +{ + int sumNums = 0, i; + + for (i = 0; i < COMBSN; i++) + sumNums += *(arr + i); + + return (sumNums >= y1 && sumNums <= y2) ? true : false; } -int factorial(int num) +int frequency() { - int i, fac; - for (i = 1, fac = 1; i <= num; i++) fac *= i; + +} + + +long int combinations_count(int N) // wtf ??????? +{ + return (factorial(N) / (factorial(COMBSN) * factorial(N - COMBSN))); +} + + +long double factorial(int num) +{ + int i; + long double fac; + if (num == 0) return -1; + else for (i = 1, fac = 1; i <= num; i++) fac *= i; return fac; -}- \ No newline at end of file +} + + +void print_other(int N, int unFrstCond, int unScndCondOnly, int printed) +{ + printf("\nTotal number of combinations %d to %d: %ld\n", N, COMBSN, combinations_count(N)); + printf("Number of combinations not satisfying the first condition: %d\n", unFrstCond); + printf("Number of combinations not satisfying the second condition only: %d\n", unScndCondOnly); + printf("Printed combinations: %d\n", printed); +} diff --git a/assignment-1.5-arrays-pointers-files/combinations/src/main.c b/assignment-1.5-arrays-pointers-files/combinations/src/main.c @@ -6,20 +6,16 @@ int main(int argc, char **argv) { - int N, K; - int *arr; - int x1, x2, y1, y2; + int *arr, N, x1, x2, y1, y2; N = get_n(); + arr = fill_array(N); quicksort(arr, 0, N-1); - //printarray(arr, N); - x_pair(&x1, &x2); y_pair(&y1, &y2); + print_combs(arr, N, x1, x2, y1, y2); - combinations(arr, x1, x2, y1, y2); - free(arr); return 0; diff --git a/assignment-1.5-arrays-pointers-files/combinations/txt/data.txt b/assignment-1.5-arrays-pointers-files/combinations/txt/data.txt @@ -1,45 +1,17 @@ -40 -20 -44 -6 -5 -7 -8 +1 +10 +11 9 10 -13 11 -12 -26 -24 -22 -3 -33 -32 -31 -29 -28 -27 -23 -48 -47 -46 -45 -43 -42 -41 -40 -39 -38 -37 -36 -35 -34 -2 -4 +15 +20 +21 +5 +6 +7 1 -49 2 5 22 -190- \ No newline at end of file +180+ \ No newline at end of file diff --git a/assignment-1.5-arrays-pointers-files/combinations/txt/data40.txt b/assignment-1.5-arrays-pointers-files/combinations/txt/data40.txt @@ -0,0 +1,47 @@ +1 +40 +41 +20 +44 +6 +5 +7 +8 +9 +10 +13 +11 +12 +26 +24 +22 +3 +33 +32 +31 +29 +28 +27 +23 +48 +47 +46 +45 +43 +42 +41 +40 +39 +38 +37 +36 +35 +34 +2 +4 +1 +49 +2 +5 +22 +190+ \ No newline at end of file diff --git a/assignment-1.5-arrays-pointers-files/combinations/txt/data49.txt b/assignment-1.5-arrays-pointers-files/combinations/txt/data49.txt @@ -0,0 +1,54 @@ +49 +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +2 +5 +22 +240+ \ No newline at end of file diff --git a/assignment-1.5-arrays-pointers-files/documentation/assignment-1.5.pdf b/assignment-1.5-arrays-pointers-files/documentation/assignment-1.5.pdf Binary files differ. diff --git a/assignment-1.5-arrays-pointers-files/documentation/assignment-1.5.synctex.gz b/assignment-1.5-arrays-pointers-files/documentation/assignment-1.5.synctex.gz Binary files differ. diff --git a/assignment-1.5-arrays-pointers-files/documentation/assignment-1.5.tex b/assignment-1.5-arrays-pointers-files/documentation/assignment-1.5.tex @@ -87,6 +87,8 @@ $ make run ARGS=txt/data.txt #fcombinations ONLY $ make clean #optional \end{lstlisting} + \subsection{Δομή φακέλων} + \section{combinations - συνδυασμοί} @@ -96,18 +98,38 @@ $ make clean #optional \subsection{combinations.c} \lstinputlisting[language=C]{../combinations/src/combinations.c} - \subsection{arrhandler.c} - \lstinputlisting[language=C]{../combinations/src/arrhandler.c} - \subsection{combinations.h} \lstinputlisting[language=C]{../combinations/include/combinations.h} + \subsection{arrhandler.c} + \lstinputlisting[language=C]{../combinations/src/arrhandler.c} + \subsection{arrhandler.h} \lstinputlisting[language=C]{../combinations/include/arrhandler.h} \subsection{Περιγραφή υλοποιήσης} - + +\section{kcombinations - συνδυασμοί με K} + + \subsection{main.c} + \lstinputlisting[language=C]{../kcombinations/src/main.c} + + \subsection{kcombinations.c} + \lstinputlisting[language=C]{../kcombinations/src/kcombinations.c} + + \subsection{kcombinations.h} + \lstinputlisting[language=C]{../kcombinations/include/kcombinations.h} + + \subsection{arrhandler.c} + \lstinputlisting[language=C]{../kcombinations/src/arrhandler.c} + + \subsection{arrhandler.h} + \lstinputlisting[language=C]{../kcombinations/include/arrhandler.h} + + \subsection{Περιγραφή υλοποιήσης} + + \section{fcombinations - συνδυασμοί από αρχείο} \subsection{main.c} @@ -116,18 +138,17 @@ $ make clean #optional \subsection{fcombinations.c} \lstinputlisting[language=C]{../fcombinations/src/fcombinations.c} - \subsection{arrhandler.c} - \lstinputlisting[language=C]{../fcombinations/src/arrhandler.c} - \subsection{fcombinations.h} \lstinputlisting[language=C]{../fcombinations/include/fcombinations.h} + \subsection{arrhandler.c} + \lstinputlisting[language=C]{../fcombinations/src/arrhandler.c} + \subsection{arrhandler.h} \lstinputlisting[language=C]{../fcombinations/include/arrhandler.h} \subsection{Περιγραφή υλοποιήσης} - \section{minesweeper - ναρκαλιευτής} @@ -140,8 +161,13 @@ $ make clean #optional \subsection{minesweeper.h} \lstinputlisting[language=C]{../minesweeper/include/minesweeper.h} - \subsection{Περιγραφή υλοποιήσης} + \subsection{gameplay.c} + \lstinputlisting[language=C]{../minesweeper/src/minesweeper.c} + \subsection{gameplay.h} + \lstinputlisting[language=C]{../minesweeper/include/gameplay.h} + + \subsection{Περιγραφή υλοποιήσης} \section{Διευκρινήσεις} diff --git a/assignment-1.5-arrays-pointers-files/fcombinations/bin/fcombs b/assignment-1.5-arrays-pointers-files/fcombinations/bin/fcombs Binary files differ. diff --git a/assignment-1.5-arrays-pointers-files/fcombinations/include/arrhandler.h b/assignment-1.5-arrays-pointers-files/fcombinations/include/arrhandler.h @@ -9,19 +9,5 @@ bool exists_in_array(int *, int, int); void quicksort(int *, int, int); int partition(int *, int, int); void swap(int *, int *); -void printarray(int *, int); - -void combinations(int *, int, int, int, int); -int even_calc(int *); -bool belongs_x(int, int, int); -int sum_calc(int *); -bool belongs_y(int, int, int); -int sum_comb_calc(); - -void print(); -int not_printed(); -int not_first_condition(); -int not_second_condition_only(); -int frequency(); #endif \ No newline at end of file diff --git a/assignment-1.5-arrays-pointers-files/fcombinations/include/ccolors.h b/assignment-1.5-arrays-pointers-files/fcombinations/include/ccolors.h @@ -1,31 +0,0 @@ -#ifndef C_COLORS_H -#define C_COLORS_H - -#include <stdio.h> - -enum options {RED, GREEN, YELLOW, BLUE, MAGENTA, CYAN, BOLD_RED, BOLD_GREEN, BOLD_YELLOW, BOLD_BLUE, BOLD_MAGENTA, BOLD_CYAN, STANDARD}; -enum options color; - -void set_color(enum options color) -{ - switch (color) - { - case RED: printf("\033[0;31m"); break; - case GREEN: printf("\033[0;32m"); break; - case YELLOW: printf("\033[0;33m"); break; - case BLUE: printf("\033[0;34m"); break; - case MAGENTA: printf("\033[0;35m"); break; - case CYAN: printf("\033[0;36m"); break; - - case BOLD_RED: printf("\033[1;31m"); break; - case BOLD_GREEN: printf("\033[1;32m"); break; - case BOLD_YELLOW: printf("\033[1;33m"); break; - case BOLD_BLUE: printf("\033[1;34m"); break; - case BOLD_MAGENTA: printf("\033[1;35m"); break; - case BOLD_CYAN: printf("\033[1;36m"); break; - - case STANDARD: printf("\033[0m"); break; - } -} - -#endif- \ No newline at end of file diff --git a/assignment-1.5-arrays-pointers-files/fcombinations/include/fcombinations.h b/assignment-1.5-arrays-pointers-files/fcombinations/include/fcombinations.h @@ -3,31 +3,22 @@ #include <stdbool.h> -void read_file(); +#define COMBSN 6 -int get_n(); -int get_k(); -int *fill_array(int); -bool exists_in_array(int *, int, int); -int *sort(int *); +void read_file(); void x_pair(int *, int *); void y_pair(int *, int *); -void combinations(int *, int, int, int, int); -int even_calc(int *); -bool belongs_x(int, int, int); -int sum_calc(int *); -bool belongs_y(int, int, int); -void print_combs(int *); -int combinations_count(int); -int factorial(int); -int sum_comb_calc(); - -void print(); -int not_printed(); -int not_first_condition(); -int not_second_condition_only(); +void print_combs(int *, int, int, int, int, int); +void combinations(int *, int *, int, int, int, int *, int *, int *, int, int, int, int); + +bool even_calc(int *, int, int); +bool sum_comb_calc(int *, int, int); + int frequency(); +long int combinations_count(int); +long double factorial(int); +void print_other(int, int, int, int); // add freq #endif diff --git a/assignment-1.5-arrays-pointers-files/fcombinations/obj/arrhandler.o b/assignment-1.5-arrays-pointers-files/fcombinations/obj/arrhandler.o Binary files differ. diff --git a/assignment-1.5-arrays-pointers-files/fcombinations/obj/fcombinations.o b/assignment-1.5-arrays-pointers-files/fcombinations/obj/fcombinations.o Binary files differ. diff --git a/assignment-1.5-arrays-pointers-files/fcombinations/obj/main.o b/assignment-1.5-arrays-pointers-files/fcombinations/obj/main.o Binary files differ. diff --git a/assignment-1.5-arrays-pointers-files/fcombinations/src/arrhandler.c b/assignment-1.5-arrays-pointers-files/fcombinations/src/arrhandler.c @@ -1,22 +1,17 @@ #include <stdio.h> #include <stdlib.h> #include "arrhandler.h" -//#include "ccolors.h" - -#define COMBSN 6 +#include "fcombinations.h" int *fill_array(int N) { - int *arr, num, i = 0; - - arr = (int *)malloc(N * sizeof(int)); + int num, i = 0; + int *arr = (int *)malloc(N * sizeof(int)); if (arr == NULL) { - //set_color(BOLD_RED); printf("Error! Not enough memory, exiting...\n"); - //set_color(STANDARD); exit(EXIT_FAILURE); } else @@ -81,81 +76,4 @@ void swap(int *a, int *b) int temp = *a; *a = *b; *b = temp; -} - - -void printarray(int *arr, int N) -{ - for (int i = 0; i < N; i++) - printf("arr[%d] = %d\n", i, *(arr + i)); -} - -int even_calc(int *arr) -{ - -} - - -bool belongs_x(int numEven, int x1, int x2) -{ - -} - - -int sum_calc(int *arr) -{ - -} - - -bool belongs_y(int sumNums, int y1, int y2) -{ - -} - - -void print_combs(int *arr) -{ - int i; - - for (i = 0; i < COMBSN; i++) - printf("%d ", *(arr + i)); - printf("\n"); -} - - -void print(int N) -{ - -} - - - -int sum_comb_calc() -{ - -} - - -int not_printed() -{ - -} - - -int not_first_condition() -{ - -} - - -int not_second_condition_only() -{ - -} - - -int frequency() -{ - } \ No newline at end of file diff --git a/assignment-1.5-arrays-pointers-files/fcombinations/src/fcombinations.c b/assignment-1.5-arrays-pointers-files/fcombinations/src/fcombinations.c @@ -3,7 +3,6 @@ #include <stdbool.h> #include <string.h> #include "fcombinations.h" -#include "ccolors.h" #define COMBSN 6 @@ -14,9 +13,7 @@ void read_file(char **argv) if (dataFile == NULL) { - set_color(BOLD_RED); printf("Error opening the file, exiting...\n"); - set_color(STANDARD); exit(EXIT_FAILURE); } else @@ -53,38 +50,101 @@ void y_pair(int *y1, int *y2) } -void combinations(int *arr, int x1, int x2, int y1, int y2) +void print_combs(int *arr, int N, int x1, int x2, int y1, int y2) { - int i, j, temp; + int *currComb = (int *)malloc(N * sizeof(int)); + int unFrstCond = 0, unScndCondOnly = 0, printed = 0; - for (i = 1; i <= COMBSN; i++) + if (currComb == NULL) { - for (j = 0; j < COMBSN-1; j++) + printf("Error! Not enough memory, exiting...\n"); + exit(EXIT_FAILURE); + } + else + { + combinations(arr, currComb, 0, N-1, 0, &printed, &unFrstCond, &unScndCondOnly, x1, x2, y1, y2); + print_other(N, unFrstCond, unScndCondOnly, printed); + } + + free(currComb); +} + + +void combinations(int *arr, int *currComb, int start, int end, int index, int *printed, int *unFrstCond, int *unScndCondOnly, int x1, int x2, int y1, int y2) +{ + int i, j; + + if (index == COMBSN) + { + for (j = 0; j < COMBSN; j++) { - temp = *(arr + j); - *(arr + j) = *(arr + j + 1); - *(arr + j + 1) = temp; - } + if (even_calc(currComb, x1, x2) && sum_comb_calc(currComb, y1, y2)) + { + printf("%d ", *(currComb + j)); + if (j == COMBSN - 1) { (*printed)++; printf("\n"); } + } // add freq + } + if (!even_calc(currComb, x1, x2) && sum_comb_calc(currComb, y1, y2)) (*unFrstCond)++; + if (!sum_comb_calc(currComb, y1, y2)) (*unScndCondOnly)++; + return; + } + + for (i = start; i <= end && end-i+1 >= COMBSN-index; i++) + { + *(currComb + index) = *(arr + i); + combinations(arr, currComb, i+1, end, index+1, printed, unFrstCond, unScndCondOnly, x1, x2, y1, y2); } } -int combinations_count(int N) +bool even_calc(int *arr, int x1, int x2) { - int numCombinations; + int numEven = 0, i; - numCombinations = factorial(N) / (factorial(COMBSN) * factorial(N - COMBSN)); + for (i = 0; i < COMBSN; i++) + if (*(arr + i) % 2 == 0) numEven++; - return numCombinations; + return (numEven >= x1 && numEven <= x2) ? true : false; } -int factorial(int num) +bool sum_comb_calc(int *arr, int y1, int y2) { - int i, fac; + int sumNums = 0, i; + + for (i = 0; i < COMBSN; i++) + sumNums += *(arr + i); + + return (sumNums >= y1 && sumNums <= y2) ? true : false; +} + - for (i = 1, fac = 1; i <= num; i++) - fac *= i; +int frequency() +{ +} + + +long int combinations_count(int N) // wtf ??????? +{ + return (factorial(N) / (factorial(COMBSN) * factorial(N - COMBSN))); +} + + +long double factorial(int num) +{ + int i; + long double fac; + if (num == 0) return -1; + else for (i = 1, fac = 1; i <= num; i++) fac *= i; return fac; +} + + +void print_other(int N, int unFrstCond, int unScndCondOnly, int printed) +{ + printf("\nTotal number of combinations %d to %d: %ld\n", N, COMBSN, combinations_count(N)); + printf("Number of combinations not satisfying the first condition: %d\n", unFrstCond); + printf("Number of combinations not satisfying the second condition only: %d\n", unScndCondOnly); + printf("Printed combinations: %d\n", printed); } \ No newline at end of file diff --git a/assignment-1.5-arrays-pointers-files/fcombinations/txt/data.txt b/assignment-1.5-arrays-pointers-files/fcombinations/txt/data.txt @@ -0,0 +1,17 @@ +1 +10 +11 +9 +10 +11 +15 +20 +21 +5 +6 +7 +1 +2 +5 +22 +180+ \ No newline at end of file diff --git a/assignment-1.5-arrays-pointers-files/fcombinations/txt/data40.txt b/assignment-1.5-arrays-pointers-files/fcombinations/txt/data40.txt @@ -0,0 +1,47 @@ +1 +40 +41 +20 +44 +6 +5 +7 +8 +9 +10 +13 +11 +12 +26 +24 +22 +3 +33 +32 +31 +29 +28 +27 +23 +48 +47 +46 +45 +43 +42 +41 +40 +39 +38 +37 +36 +35 +34 +2 +4 +1 +49 +2 +5 +22 +190+ \ No newline at end of file diff --git a/assignment-1.5-arrays-pointers-files/fcombinations/txt/data49.txt b/assignment-1.5-arrays-pointers-files/fcombinations/txt/data49.txt @@ -0,0 +1,54 @@ +49 +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +2 +5 +22 +240+ \ No newline at end of file diff --git a/assignment-1.5-arrays-pointers-files/kcombinations/Makefile b/assignment-1.5-arrays-pointers-files/kcombinations/Makefile @@ -0,0 +1,36 @@ +TARGET = kcombs + +SRC_DIR = src +OBJ_DIR = obj +BIN_DIR = bin + +SRC = $(wildcard $(SRC_DIR)/*.c) +OBJ = $(SRC:$(SRC_DIR)/%.c=$(OBJ_DIR)/%.o) + +MOVE = mv +MKDIR_P = mkdir -p + +CC = gcc +CPPFLAGS += -Iinclude +CFLAGS += -Wall +LDFLAGS += -Llib +LDLIBS += -lm + +.PHONY: all clean + +all: $(TARGET) + +$(TARGET): $(OBJ) + $(MKDIR_P) $(BIN_DIR) + $(CC) $(LDFLAGS) $^ $(LDLIBS) -o $@ + $(MOVE) $(TARGET) $(BIN_DIR) + +$(OBJ_DIR)/%.o: $(SRC_DIR)/%.c + $(MKDIR_P) $(OBJ_DIR) + $(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@ + +run: + ./$(BIN_DIR)/$(TARGET) + +clean: + $(RM) $(OBJ) $(BIN_DIR)/$(TARGET)+ \ No newline at end of file diff --git a/assignment-1.5-arrays-pointers-files/kcombinations/bin/combs b/assignment-1.5-arrays-pointers-files/kcombinations/bin/combs Binary files differ. diff --git a/assignment-1.5-arrays-pointers-files/kcombinations/include/arrhandler.h b/assignment-1.5-arrays-pointers-files/kcombinations/include/arrhandler.h @@ -0,0 +1,13 @@ +#ifndef ARRHANDLER_H +#define ARRHANDLER_H + +#include <stdbool.h> + +int *fill_array(int); +bool exists_in_array(int *, int, int); + +void quicksort(int *, int, int); +int partition(int *, int, int); +void swap(int *, int *); + +#endif+ \ No newline at end of file diff --git a/assignment-1.5-arrays-pointers-files/kcombinations/include/kcombinations.h b/assignment-1.5-arrays-pointers-files/kcombinations/include/kcombinations.h @@ -0,0 +1,20 @@ +#ifndef COMBINATIONS_H +#define COMBINATIONS_H + +#include <stdbool.h> + +void x_pair(int *, int *); +void y_pair(int *, int *); + +void print_combs(int *, int, int, int, int, int, int); +void combinations(int *, int *, int, int, int, int, int *, int *, int *, int, int, int, int); + +bool even_calc(int *, int, int, int); +bool sum_comb_calc(int *, int, int, int); + +int frequency(); +long int combinations_count(int, int); +long double factorial(int); +void print_other(int, int, int, int, int); // add freq + +#endif+ \ No newline at end of file diff --git a/assignment-1.5-arrays-pointers-files/kcombinations/obj/arrhandler.o b/assignment-1.5-arrays-pointers-files/kcombinations/obj/arrhandler.o Binary files differ. diff --git a/assignment-1.5-arrays-pointers-files/kcombinations/obj/kcombinations.o b/assignment-1.5-arrays-pointers-files/kcombinations/obj/kcombinations.o Binary files differ. diff --git a/assignment-1.5-arrays-pointers-files/kcombinations/obj/main.o b/assignment-1.5-arrays-pointers-files/kcombinations/obj/main.o Binary files differ. diff --git a/assignment-1.5-arrays-pointers-files/kcombinations/src/arrhandler.c b/assignment-1.5-arrays-pointers-files/kcombinations/src/arrhandler.c @@ -0,0 +1,79 @@ +#include <stdio.h> +#include <stdlib.h> +#include "arrhandler.h" +#include "kcombinations.h" + + +int *fill_array(int N) +{ + int num, i = 0; + int *arr = (int *)malloc(N * sizeof(int)); + + if (arr == NULL) + { + printf("Error! Not enough memory, exiting...\n"); + exit(EXIT_FAILURE); + } + else + { + do + { + printf("arr[%d]: ", i); + scanf("%d", &num); + + if (num >= 1 && num <= 49) + { + if (i == 0) { *(arr + i) = num; i++; } + else + { + if (!exists_in_array(arr, N, num)) { *(arr + i) = num; i++; } + else printf("Give a different number.\n"); + } + } + else printf("Give a number in [1, 49].\n"); + } while (i < N); + } + + return arr; +} + + +bool exists_in_array(int *arr, int N, int num) +{ + int *arrEnd = arr + (N - 1); + while (arr <= arrEnd && *arr != num) arr++; + return (arr <= arrEnd) ? true : false; +} + + +void quicksort(int *arr, int low, int high) +{ + if (low < high) + { + int partIndex = partition(arr, low, high); + quicksort(arr, low, partIndex - 1); + quicksort(arr, partIndex + 1, high); + } +} + + +int partition(int *arr, int low, int high) +{ + int pivot = *(arr + high); + int i = (low - 1), j; + + for (j = low; j <= high - 1; j++) + if (*(arr + j) < pivot) + swap(arr + ++i, arr + j); + + swap(arr + (i + 1), arr + high); + return (i + 1); +} + + +void swap(int *a, int *b) +{ + int temp = *a; + *a = *b; + *b = temp; +}+ \ No newline at end of file diff --git a/assignment-1.5-arrays-pointers-files/kcombinations/src/kcombinations.c b/assignment-1.5-arrays-pointers-files/kcombinations/src/kcombinations.c @@ -0,0 +1,160 @@ +#include <stdio.h> +#include <stdlib.h> +#include <stdbool.h> +#include "kcombinations.h" +#include "arrhandler.h" + + +int get_n() +{ + int N; + + do + { + system("clear||cls"); + printf("N (6 < N <= 49): "); + scanf("%d", &N); + } while (N <= 6 || N > 49); + + return N; +} + + +int get_k(int N) +{ + int K; + + do + { + printf("K (K < N <= 49): "); + scanf("%d", &K); + } while (K >= N || K > 49); + + system("clear||cls"); + + return K; +} + + +void x_pair(int *x1, int *x2) +{ + do + { + printf("x1: "); + scanf("%d", x1); + printf("x2: "); + scanf("%d", x2); + } while (*x1 < 0 || *x1 > *x2 || *x2 > 6); +} + + +void y_pair(int *y1, int *y2) +{ + do + { + printf("y1: "); + scanf("%d", y1); + printf("y2: "); + scanf("%d", y2); + } while (*y1 < 21 || *y1 > *y2 || *y2 > 279); +} + + +void print_combs(int *arr, int N, int K, int x1, int x2, int y1, int y2) +{ + int *currComb = (int *)malloc(N * sizeof(int)); + int unFrstCond = 0, unScndCondOnly = 0, printed = 0; + + if (currComb == NULL) + { + printf("Error! Not enough memory, exiting...\n"); + exit(EXIT_FAILURE); + } + else + { + combinations(arr, currComb, 0, N-1, 0, K, &printed, &unFrstCond, &unScndCondOnly, x1, x2, y1, y2); + print_other(N, K, unFrstCond, unScndCondOnly, printed); + } + + free(currComb); +} + + +void combinations(int *arr, int *currComb, int start, int end, int index, int K, int *printed, int *unFrstCond, int *unScndCondOnly, int x1, int x2, int y1, int y2) +{ + int i, j; + + if (index == K) + { + for (j = 0; j < K; j++) + { + if (even_calc(currComb, K, x1, x2) && sum_comb_calc(currComb, K, y1, y2)) + { + printf("%d ", *(currComb + j)); + if (j == K - 1) { (*printed)++; printf("\n"); } + } // add freq + } + if (!even_calc(currComb, K, x1, x2) && sum_comb_calc(currComb, K, y1, y2)) (*unFrstCond)++; + if (!sum_comb_calc(currComb, K, y1, y2)) (*unScndCondOnly)++; + return; + } + + for (i = start; i <= end && end-i+1 >= K-index; i++) + { + *(currComb + index) = *(arr + i); + combinations(arr, currComb, i+1, end, index+1, K, printed, unFrstCond, unScndCondOnly, x1, x2, y1, y2); + } +} + + +bool even_calc(int *arr, int K, int x1, int x2) +{ + int numEven = 0, i; + + for (i = 0; i < K; i++) + if (*(arr + i) % 2 == 0) numEven++; + + return (numEven >= x1 && numEven <= x2) ? true : false; +} + + +bool sum_comb_calc(int *arr, int K, int y1, int y2) +{ + int sumNums = 0, i; + + for (i = 0; i < K; i++) + sumNums += *(arr + i); + + return (sumNums >= y1 && sumNums <= y2) ? true : false; +} + + +int frequency() +{ + +} + + +long int combinations_count(int N, int K) // wtf ??????? +{ + return (factorial(N) / (factorial(K) * factorial(N - K))); +} + + +long double factorial(int num) +{ + int i; + long double fac; + if (num == 0) return -1; + else for (i = 1, fac = 1; i <= num; i++) fac *= i; + return fac; +} + + +void print_other(int N, int K, int unFrstCond, int unScndCondOnly, int printed) +{ + printf("\nTotal number of combinations %d to %d: %ld\n", N, K, combinations_count(N, K)); + printf("Number of combinations not satisfying the first condition: %d\n", unFrstCond); + printf("Number of combinations not satisfying the second condition only: %d\n", unScndCondOnly); + printf("Printed combinations: %d\n", printed); +} diff --git a/assignment-1.5-arrays-pointers-files/kcombinations/src/main.c b/assignment-1.5-arrays-pointers-files/kcombinations/src/main.c @@ -0,0 +1,23 @@ +#include <stdio.h> +#include <stdlib.h> +#include "kcombinations.h" +#include "arrhandler.h" + + +int main(int argc, char **argv) +{ + int *arr, N, K, x1, x2, y1, y2; + + N = get_n(); + K = get_k(N); + + arr = fill_array(N); + quicksort(arr, 0, N-1); + x_pair(&x1, &x2); + y_pair(&y1, &y2); + print_combs(arr, N, K, x1, x2, y1, y2); + + free(arr); + + return 0; +}+ \ No newline at end of file diff --git a/assignment-1.5-arrays-pointers-files/kcombinations/txt/kdata.txt b/assignment-1.5-arrays-pointers-files/kcombinations/txt/kdata.txt @@ -0,0 +1,16 @@ +10 +8 +9 +10 +11 +15 +20 +21 +5 +6 +7 +1 +2 +5 +22 +180+ \ No newline at end of file diff --git a/assignment-1.5-arrays-pointers-files/kcombinations/txt/kdata40.txt b/assignment-1.5-arrays-pointers-files/kcombinations/txt/kdata40.txt @@ -0,0 +1,47 @@ +40 +5 +20 +44 +6 +5 +7 +8 +9 +10 +13 +11 +12 +26 +24 +22 +3 +33 +32 +31 +29 +28 +27 +23 +48 +47 +46 +45 +43 +42 +41 +40 +39 +38 +37 +36 +35 +34 +2 +4 +5 +1 +49 +2 +5 +22 +200+ \ No newline at end of file diff --git a/assignment-1.5-arrays-pointers-files/kcombinations/txt/kdata49.txt b/assignment-1.5-arrays-pointers-files/kcombinations/txt/kdata49.txt @@ -0,0 +1,55 @@ +49 +30 +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +2 +5 +22 +240+ \ No newline at end of file diff --git a/assignment-1.5-arrays-pointers-files/fcombinations/txt/data.txt b/assignment-1.5-arrays-pointers-files/kcombinations/txt/koutput.txt diff --git a/assignment-1.5-arrays-pointers-files/minesweeper/bin/minesweeper b/assignment-1.5-arrays-pointers-files/minesweeper/bin/minesweeper Binary files differ. diff --git a/assignment-1.5-arrays-pointers-files/minesweeper/mnsout.txt b/assignment-1.5-arrays-pointers-files/minesweeper/mnsout.txt @@ -1,24 +1,116 @@ -Mine hit at position (6, 7) +Mine hit at position (23, 22) Board overview -- 1 1 1 - - - - - - 1 1 1 - - - - - - - -- 1 * 1 - - - - - - 1 * 1 1 1 1 - - - - -- 1 1 1 - - - - - - 1 1 1 1 * 1 - - - - -- - 1 1 1 - - - - - - - - 1 1 1 - - - - -- - 1 * 1 - - - - - - - - - - - - - - - -- - 1 1 1 - 1 1 1 - - - - - - - - - - - -- - - - - - 1 * 1 - - - - - 1 1 1 - - - -- - - 1 1 1 1 1 1 - - - - - 1 * 1 - - - -- - - 1 * 1 - - - - - - - - 1 1 1 - - - -- - - 1 1 1 - - - - - - 1 1 1 - - - - - -1 1 1 - - - - - - - - - 1 * 1 - - - - - -1 * 1 - - - - - - - - - 1 1 1 - - - - - -1 1 1 - - - - - - - - - - - 1 1 1 - - - -- - - - - - - - - - - - - - 1 * 1 - - - -- - - - - - - - - - - - - - 1 1 1 - - - -- - - - - - - - - - - - - - - - - - - - -- - - - - - - - - - - - - - - - - - - - -- - - - - - - - - - - - - - - - - - - - -- - - - - - - - - - - - - - - - - - - - -- - - - - - - - - - - - - - - - - - - - +- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1 1 1 - - - +- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1 * 1 - - - +- - - - - - - - - - - - - - - - - - - - - - - - - 1 1 1 - - - - - - 1 1 1 - - - +- 1 1 1 - - - - - - - - - - - - - - - - - - - - - 1 * 1 - - - - - - - - - - - - +- 1 * 1 - - - - - - - - - - - - - - - - - - - - - 1 1 1 - - - - - - - - - - - - +- 1 1 1 - - - - - - - - - - - - - - - - - - - - - - - 1 1 1 - - - - - - - - - - +- - - - - - - - - - - - - - - - - - - - - - - - - - - 1 * 1 - - - - - - - - - - +- - - - - - - - - - - - - - - - - - - - - - - - - - - 1 1 1 - - - - - - - - - - +- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +- 1 1 1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +- 1 * 1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +- 1 1 1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +- - - - - - - - - - - - - - - - - - - - - 1 1 1 - - - - - - - - - - - - - - - - +- - - - - - - - - - - - - - - - - - - - - 1 * 1 - - 1 1 1 - - - - - - - - - - - +- - - - - - - - - - - - - - - - - - - - - 1 1 1 - - 2 * 2 - - - - - - - - - - - +- - - - - - - - - - - 1 1 1 - - - - - - - - - - - - 2 * 2 - - - - - - - - - - - +- - - - - - - - - - - 1 * 1 - - - - - - - - - - - - 1 1 1 - - - - - - - - - - - +- - - - - - - - - - - 1 1 1 - - - - - - - - - - - - - - - - - - - - - - - - - - +- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +- - - - - - 1 1 1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +- - - - - - 1 * 1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +- - - - - - 1 1 1 - - - - - - - - - - - - - - - 1 1 1 - - - - - - - - - - - - - +- - - - - - - - - - - - - - - - - - - - - - - - 1 * 1 - - 1 1 1 - - - - - - - - +- - - - - - - - - - - - - - - - - - - - - - - - 1 1 1 - - 1 * 1 - - - - - - - - +- - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1 1 1 - - - - - - - - +- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +- - - - - - - - - - - - - - - - - - - - 1 2 2 1 - - - - - - - - - - - - - - - - +- - - - - - - - - - - - - - - - - - - - 1 * * 1 - - - - - - - - - - - - - - - - +- - - - - - - - - - - - - - - - - - - - 1 2 2 1 - - - - - - - - - - - - - - - - +- - - - - - - - - - - - - - - 1 1 1 - - - - - - - - - - - - - - - - - - - - - - +- - - - - - - - - - - - - - - 1 * 1 1 1 1 - - - - - - - - - - - - 1 1 1 - - - - +- - - - - - - - - - - - - - - 1 1 1 1 * 1 - - - - - - - - - - - - 1 * 1 - - - - +- - - - - - 1 1 1 - - - - - - - - - 1 1 1 - - - - - - - - - - - - 1 1 1 - - - - +- - - - - - 1 * 1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +- - - - - - 1 1 1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +- - - - - - - - 1 1 1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +- - - - - - - - 1 * 1 - - - - - - - - - - - - - - - - - - - - - - - - - - 1 1 1 +- - - - - - - - 1 1 1 - - - - - - - - - - - - - - - - - - - - - - 1 1 1 - 1 * 1 +- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1 * 1 - 1 1 1 +- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1 1 1 - - - - +- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +- - - - - - - - - - - - - - - - - - - - - - 1 1 1 - - - - - - - - - - - - - - - +- - - - - - - - - - - - - - - - - - - - - - 1 * 1 - - - - - - - - - - - - - - - +- - - - - - - - - - - - - - - - - - - - 1 1 2 1 1 - - - - - - - - - - - - - - - +- - - - - - - - - - - - - - - - - - - - 1 * 1 - - - - - - - - - - - - - - - - - +- - - - - - - - - - - - - - - - - - - - 1 1 1 - - - - - - - - - - - - - - - - - +1 1 1 - - - - - - - - - - - - - - - - - - 1 1 1 - - - - - - - - - - - - - - - - +1 * 1 - - - - - - - - - - - - - - - - - - 1 * 1 - - - - - - - - - - - - - - - - +1 1 1 - 1 1 1 - - - - 1 1 1 - - - - - - - 1 1 1 - - - - - - - - - - - - - - - - +- - - - 1 * 1 - - - - 1 * 1 - - - - - - - - - - - - - - - - - - - - - - - - - - +- - - - 1 1 1 - - - - 1 1 1 - - - - - - - - - - - - - - - - - - - - - - - - - - +- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +- - - - - - - - - - - - - - - - - 1 1 1 - - - 1 1 1 - - - - - - - - - - - - - - +- - - - - - - - - - - - - - - - - 1 * 1 - - - 1 * 1 - - - - - - - - - - - - - - +- - - - - - - - - - - - - - - - - 1 1 1 - - - 1 1 1 - - - - - - - - - - - - - - +- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +- - 1 1 1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +- - 1 * 1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +- - 1 1 1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +- - - - - - - - - - - - - - - - - - - - 1 1 1 - - - - - - - - - - - - - - - - - +- - - - - - - - - - - - - - - - - - - - 1 * 1 - - - - - - - - - - - - - - - - - +- - - - - - - - - - - - - - - - - - - - 1 1 1 - - - - - - - - - - - - - - - - - +- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +- - - - - - - - - - - - - - - - 1 1 1 - - - - - - - - - - - - - - - - - - - - - +1 1 - - - - - - - - - - - - - - 1 * 1 - - - - - - - - - - - - - - - - - - - - - +* 1 - - - - - - - - - - - - - - 1 1 1 - - - - - - - - - - - - - - - - - - - - - +1 1 - - - - - - - - - - - - - - 1 1 1 - - - - - - - - - - - - - - - - - - - - - +- - - - - - - - - - - - - - - - 1 * 1 - - - - - - - - - - - - - - - - - - - - - +- - - - - - - - - - - - - - - - 1 1 1 - - - - - - - - - - - - - - - - - - - - - +- - - - - - - - - - - - - - - - - - 1 1 1 - - - - - - - - - - - - - - - - - - - +- - - - - - - - - - - - - - - - - - 1 * 1 - - - - - - - - - - - - - - - - - - - +- - - - - - - - - - - - - - - - - - 1 1 1 - - - - - - - - - - - - - - - - - - - +- - - - - - - - - - - - - - - 1 1 1 - - - - - - - - - - - - - - - - - - - - - - +- - - - - - - - - - - - - - - 1 * 1 - - - - - - - - - - - - - - - - - - - - - - +- - - - - - - - - - - - - - - 1 1 1 - - - - - - - - - - - - - - - - - - - - - - +- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +- - - - - - - - 1 1 1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +- - - - - - - - 1 * 1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +- - - - - - - - 1 1 1 - - - - - - - - - - - - - - - - - - - - - - - - - - 1 1 1 +- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1 * 1 +- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1 1 1 +- - - - - - 1 1 1 - - - - - - - - - - - - - - - - - - - - - - - 1 1 1 - - - - - +- - - - - - 1 * 1 - - - - - - - - - - - - - - - - - - - - - - - 1 * 1 - - - - - diff --git a/assignment-1.5-arrays-pointers-files/minesweeper/obj/gameplay.o b/assignment-1.5-arrays-pointers-files/minesweeper/obj/gameplay.o Binary files differ. diff --git a/assignment-1.5-arrays-pointers-files/minesweeper/obj/main.o b/assignment-1.5-arrays-pointers-files/minesweeper/obj/main.o Binary files differ. diff --git a/assignment-1.5-arrays-pointers-files/minesweeper/obj/minesweeper.o b/assignment-1.5-arrays-pointers-files/minesweeper/obj/minesweeper.o Binary files differ. diff --git a/assignment-1.5-arrays-pointers-files/notes.md b/assignment-1.5-arrays-pointers-files/notes.md @@ -1,21 +1,2 @@ -* multiple txt (and 49 nums) -* 6 for * meter function -* kcombinations -* ```c -void comb(int a[], int N) -{ - int i, j, k, l, m, n; - - for (i=0; i<N-5; i++) - for (j=i+1; j<N-4; j++) - for (k=j+1; k<N-3; k++) - for (l=k+1; l<N-2; l++) - for (m=l+1; m<N-1; m++) - for (n=m+1; n<N; n++) - { - printf("%d %d %d %d %d %d", a[i], a[j], a[k], a[l], a[m], a[n]); - printf("\n"); - } -} -```- \ No newline at end of file +* kcombinations+ \ No newline at end of file