uni

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

commit 1617a6590926c443b5933f200104bb6c43543040
parent 8dcfb3cecdf5a2e0b0e25e48ce7a6754aa558f3a
Author: Christos Margiolis <christos@margiolis.net>
Date:   Fri,  9 Oct 2020 01:57:29 +0300

removed bins and object files

Diffstat:
Dc-parallel-computing/ex1.c | 0
Dc-parallel-computing/ex2.c | 0
Dc-parallel-computing/ex3.c | 0
Dc-programming/1-basic-elements/examples/C1a.c | 24------------------------
Dc-programming/2-conditional-statements/examples/C2a.c | 26--------------------------
Dc-programming/2-conditional-statements/examples/C2b.c | 40----------------------------------------
Dc-programming/2-conditional-statements/examples/C2c.c | 17-----------------
Dc-programming/4-functions/README.md | 37-------------------------------------
Dc-programming/5-arrays-pointers-files/combinations/bin/combs | 0
Dc-programming/5-arrays-pointers-files/combinations/obj/arrhandler.o | 0
Dc-programming/5-arrays-pointers-files/combinations/obj/combinations.o | 0
Dc-programming/5-arrays-pointers-files/combinations/obj/main.o | 0
Dc-programming/5-arrays-pointers-files/examples/1DDynamic.c | 223-------------------------------------------------------------------------------
Dc-programming/5-arrays-pointers-files/examples/Lexico.c | 149-------------------------------------------------------------------------------
Dc-programming/5-arrays-pointers-files/examples/mystring.c | 103-------------------------------------------------------------------------------
Dc-programming/5-arrays-pointers-files/fcombinations/bin/fcombs | 0
Dc-programming/5-arrays-pointers-files/fcombinations/obj/arrhandler.o | 0
Dc-programming/5-arrays-pointers-files/fcombinations/obj/fcombinations.o | 0
Dc-programming/5-arrays-pointers-files/fcombinations/obj/main.o | 0
Dc-programming/5-arrays-pointers-files/kcombinations/bin/combs | 0
Dc-programming/5-arrays-pointers-files/kcombinations/bin/kcombs | 0
Dc-programming/5-arrays-pointers-files/kcombinations/obj/arrhandler.o | 0
Dc-programming/5-arrays-pointers-files/kcombinations/obj/kcombinations.o | 0
Dc-programming/5-arrays-pointers-files/kcombinations/obj/main.o | 0
Dc-programming/5-arrays-pointers-files/minecurses/bin/minecurses | 0
Dc-programming/5-arrays-pointers-files/minecurses/obj/audio.o | 0
Dc-programming/5-arrays-pointers-files/minecurses/obj/gameplay.o | 0
Dc-programming/5-arrays-pointers-files/minecurses/obj/main.o | 0
Dc-programming/5-arrays-pointers-files/minecurses/obj/minesweeper.o | 0
Dc-programming/5-arrays-pointers-files/minecurses/obj/navigation.o | 0
Dc-programming/5-arrays-pointers-files/minecurses/obj/outputs.o | 0
Dc-programming/5-arrays-pointers-files/minecurses/obj/settings.o | 0
Dc-programming/5-arrays-pointers-files/minecurses/obj/wins.o | 0
Dcpp-oop/1-fromctocpp/Ex1.cpp | 112-------------------------------------------------------------------------------
Dcpp-oop/2-classes/BigIntv1.cpp | 116-------------------------------------------------------------------------------
Dcpp-oop/3-operoverloading/BigIntv3.cpp | 444-------------------------------------------------------------------------------
Dcpp-oop/3-operoverloading/bin/operoverloading | 0
Dcpp-oop/3-operoverloading/obj/course.o | 0
Dcpp-oop/3-operoverloading/obj/main.o | 0
Dcpp-oop/3-operoverloading/obj/student.o | 0
Dcpp-oop/3-operoverloading/obj/subject.o | 0
Dcpp-oop/4-inheritance/bin/inheritance | 0
Dcpp-oop/4-inheritance/obj/app.o | 0
Dcpp-oop/4-inheritance/obj/appsystem.o | 0
Dcpp-oop/4-inheritance/obj/errlog.o | 0
Dcpp-oop/4-inheritance/obj/game.o | 0
Dcpp-oop/4-inheritance/obj/main.o | 0
Dcpp-oop/4-inheritance/obj/manufacturer.o | 0
Dcpp-oop/4-inheritance/obj/office.o | 0
Dcpp-oop/4-inheritance/obj/review.o | 0
Dcpp-oop/5-spreadsheets/bin/spreadsheets | 0
Dcpp-oop/5-spreadsheets/obj/datahandler.o | 0
Dcpp-oop/5-spreadsheets/obj/errlog.o | 0
Dcpp-oop/5-spreadsheets/obj/grade.o | 0
Dcpp-oop/5-spreadsheets/obj/grades.o | 0
Dcpp-oop/5-spreadsheets/obj/main.o | 0
Dcpp-oop/5-spreadsheets/obj/report.o | 0
Dcpp-oop/5-spreadsheets/obj/xstring.o | 0
58 files changed, 0 insertions(+), 1291 deletions(-)

diff --git a/c-parallel-computing/ex1.c b/c-parallel-computing/ex1.c diff --git a/c-parallel-computing/ex2.c b/c-parallel-computing/ex2.c diff --git a/c-parallel-computing/ex3.c b/c-parallel-computing/ex3.c diff --git a/c-programming/1-basic-elements/examples/C1a.c b/c-programming/1-basic-elements/examples/C1a.c @@ -1,23 +0,0 @@ -#include <stdio.h> - -int main(int argc, int **argv) -{ - int A, B; - int C, D, E, F; - system ("chcp 1253"); - printf ("Βασικές αριθμητικές πράξεις με Ακεραίους\n"); - printf ("========================================\n\n"); - printf ("Εισάγετε τον πρώτο αριθμό : "); - scanf ("%d",&A); - printf ("Εισαγετε το δεύτερο αριθμό : ); - scanf ("%d", &B); - C = A + B; - D = A - B; - E = A * B; - F = A / B; - printf ("Άθροισμα : %d\n", c); - printf ("Διαφορά : %d\n", D); - printf ("Γινόμενο : %d\n", Ε); - prantf ("Πηλίκο : %d\n", F); - return 0;; -}- \ No newline at end of file diff --git a/c-programming/2-conditional-statements/examples/C2a.c b/c-programming/2-conditional-statements/examples/C2a.c @@ -1,26 +0,0 @@ -#include <stdio.h> - -int main (int NoP, char **Params) -{ - int a, b, c; - int Max; - printf ("ΕΥΡΕΣΗ ΜΕΓΙΣΤΟΥ ΑΡΙΘΜΟΥ\n\n"); - printf ("Εισάγετε τον πρώτο αριθμό : "); - scanf ("%d", &a); - printf ("Εισάγετε τον δεύτερο αριθμό : "); - scanf ("%d", &b); - printf ("Εισάγετε τον τρίτο αριθμό : "); - scanf ("%d", &c); - Max = a; - if (b > Max) - Max = b; - Max = (c > Max)? c: Max; - printf ("Ο μεγαλύτερος είναι ο %d και εισήχθη:\n", Max); - if (Max == a) - printf(" 1ος\n"); - if (Max == b) - printf(" 2ος\n"); - if (Max == c) - printf(" 3ος\n"); - return 124; -} diff --git a/c-programming/2-conditional-statements/examples/C2b.c b/c-programming/2-conditional-statements/examples/C2b.c @@ -1,40 +0,0 @@ -#include <stdio.h> - -int main (int NoP, char **Params) -{ - int a, b, c; - int Max; - printf ("ΕΥΡΕΣΗ ΜΕΓΙΣΤΟΥ ΑΡΙΘΜΟΥ\n\n"); - printf ("Εισάγετε τον πρώτο αριθμό : "); - scanf ("%d", &a); - printf ("Εισάγετε τον δεύτερο αριθμό : "); - scanf ("%d", &b); - printf ("Εισάγετε τον τρίτο αριθμό : "); - scanf ("%d", &c); - if (a > b) - if (a > c) - printf("Ο μεγαλύτερος είναι ο %d και εισήχθη 1ος\n", a); - else - if (a == c) - printf ("Ο μεγαλύτερος είναι ο %d και εισήχθη 1ος και 3ος\n", a); - else - printf ("Ο μεγαλύτερος είναι ο %d και εισήχθη 3ος\n", c); - else - if (a == b) - if (a == c) - printf ("Ο μεγαλύτερος είναι ο %d και εισήχθη 1ος, 2ος και 3ος\n", a); - else - if (a > c) - printf ("Ο μεγαλύτερος είναι ο %d και εισήχθη 1ος και 2ος\n", a); - else - printf ("Ο μεγαλύτερος είναι ο %d και εισήχθη 3ος\n", c); - else - if (b > c) - printf ("Ο μεγαλύτερος είναι ο %d και εισήχθη 2ος\n", b); - else - if (b == c) - printf ("Ο μεγαλύτερος είναι ο %d και εισήχθη 2ος και 3ος\n", a); - else - printf ("Ο μεγαλύτερος είναι ο %d και εισήχθη 3ος\n", c); - return 32; -} diff --git a/c-programming/2-conditional-statements/examples/C2c.c b/c-programming/2-conditional-statements/examples/C2c.c @@ -1,17 +0,0 @@ -#include <stdio.h> -#define t 6 - -int main () -{ - int i = 7; - switch (i) - { - case 3: printf ("3\n"); - case 5: printf ("5\n"); break; - case 3 + 4: printf ("7\n"); - default: printf ("default\n"); - case 1: printf ("1\n"); break; - case t: printf ("t\n"); - } -} - diff --git a/c-programming/4-functions/README.md b/c-programming/4-functions/README.md @@ -1,36 +0,0 @@ -# Assignment 1.4: Functions - -## Programs - -* hanoi-tower -* menu -* sine-cos-taylor - -## Execution - -* ```program_name``` = program's name -* ```full_path/``` = full path - -### Linux - -```shell -$ cd full_path/assignment-1.4-functions/program_name -$ make -$ make run -$ make clean # optional -``` - -### Windows (not tested) - -**Dependencies:** -* MinGW gcc compiler -* ```make``` - -In CMD, do the following: - -```bat -cd full_path/assignment-1.4-functions/program_name -make -make run -make clean -```- \ No newline at end of file diff --git a/c-programming/5-arrays-pointers-files/combinations/bin/combs b/c-programming/5-arrays-pointers-files/combinations/bin/combs Binary files differ. diff --git a/c-programming/5-arrays-pointers-files/combinations/obj/arrhandler.o b/c-programming/5-arrays-pointers-files/combinations/obj/arrhandler.o Binary files differ. diff --git a/c-programming/5-arrays-pointers-files/combinations/obj/combinations.o b/c-programming/5-arrays-pointers-files/combinations/obj/combinations.o Binary files differ. diff --git a/c-programming/5-arrays-pointers-files/combinations/obj/main.o b/c-programming/5-arrays-pointers-files/combinations/obj/main.o Binary files differ. diff --git a/c-programming/5-arrays-pointers-files/examples/1DDynamic.c b/c-programming/5-arrays-pointers-files/examples/1DDynamic.c @@ -1,223 +0,0 @@ -#include <stdio.h> -#include <stdlib.h> - -int GetIntWithinLimits (int, int); -int *ReadMatrix (int); -int ReadMatrix1 (int **M, int S); -void PrintMatrix (int *, int); -int CompareMatrices (int *M1, int M2[], int S); -int GetRandom (int, int); -void RandomFill (int *, int, int, int); -int IsSorted (int *, int); -int LudicrousSort (int *, int); -void Strange1 (int *, int); - -int main (int argc, char **argv) -{ - int *Mat1; - int *Mat2; - int *Mat3; - int NoN; - - srand (time (NULL)); - - NoN = GetIntWithinLimits (1, 100000); - printf ("\n\n"); - Mat1 = ReadMatrix (NoN); - PrintMatrix (Mat1, NoN); - printf ("\n\n"); - if (ReadMatrix1 (&Mat2, NoN)) - PrintMatrix (Mat2, NoN); - else - printf ("Not enough memory...\n"); - printf ("\n\n"); - if (CompareMatrices (Mat1, Mat2, NoN)) - printf ("Matrices are Equal\n"); - else - printf ("Matrices are not Equal\n"); - printf ("\n\n"); - // Δοκιμάστε το παρακάτω για λίγο μεγαλύτερους πίνακες, π.χ. με 15 στοιχεία. - Mat3 = (int *) malloc (5 * sizeof (int)); - RandomFill (Mat3, 5, -5, 300); - PrintMatrix (Mat3, 5); - printf ("Matrix 3 Sorted. Steps: %d\n", LudicrousSort (Mat3, 5)); - PrintMatrix (Mat3, 5); - printf ("\n\n"); - Strange1 (Mat1, NoN); - PrintMatrix (Mat1, NoN); - - -} - -/** - * Διαβάζει από το πληκτρολόγιο και επιστρέφει ένα ακέραιο αριθμό μέσα σε συγκεκριμένο διάστημα. - * Παρόμοια τεχνική πρέπει να χρησιμοποιείται κάθε φορά που πρέπει να εισαχθούν τιμές και να γίνει έλεγχος ορθότητάς τους - */ -int GetIntWithinLimits (int L1, int L2) -{ - int R; - do - { - printf ("Enter an Integer Between %d and %d : ", L1, L2); - scanf ("%d", &R); - } - while (R < L1 || R > L2); - return R; -} - -/* - * Δημιουργεί έναν δυναμικά δεσμευμένο πίνακα ακεραίων συγκεκριμένου μεγέθους, τον γεμίζει με τιμές από την standard είσοδο - * και τον επιστρέφει. Σε περίπτωση προβλήματος δέσμευσης μνήμης η εκτέλεση του προγράμματος διακόπτεται. - * Πώς θα μπορούσε να επιστρέφεται η πληροφορία ότι δεν έγινε η δέσμευση μνήμης (αν αποτύχει η malloc) και να μην χρειαστεί να τερματιστεί το πρόγραμμα; - */ -int *ReadMatrix (int S) -{ - int *T, i; - T = (int *) malloc (S * sizeof (int)); - if (T == NULL) - { - //Ενημέρωση χρήστη για μοιραίο πρόβλημα... - exit (1); - } - for (i = 0; i < S; i++) - { - printf ("Enter Value for Position %d: ", i + 1); - scanf ("%d", T + i); //Γιατί T + i και όχι &T[i]; - } - return T; -} - -/* - * Δημιουργεί έναν δυναμικά δεσμευμένο πίνακα ακεραίων συγκεκριμένου μεγέθους, τον γεμίζει με τιμές από την standard είσοδο - * και επιστρέφει true αν η δέσμευση έγινε κανονικά, false διαφορετικά. - * Η διαφορά με την προηγούμενη συνάρτηση είναι ότι η διεύθυνση του πίνακα δεν επιστρέφεται με return αλλά τοποθετείται - * στον pointer που δίδεται ως είσοδος. Η τεχνική αυτή χρησιμοποιείται αν η συνάρτηση πρέπει να δημιουργήσει περισότερους - * του ενός πίνακες ή αν πρέπει να επιστρέψει και κάποια άλλη πληροφορία, όπως σε αυτή την περίπτωση. - * Είναι κατανοητό γιατί ο pointer είναι διπλός; - */ -int ReadMatrix1 (int **M, int S) -{ - int i; - *M = (int *) malloc (S * sizeof (int)); - if (*M == NULL) - return 0; - for (i = 0; i < S; i++) - { - printf ("Enter Value for Position %d: ", i + 1); - scanf ("%d", *M + i); - } - return 1; -} - -/* - * Τυπώνει τα στοιχεία ενός πίνακα ακεραίων. - * Τροποποιείστε την συνάρτηση ώστε κάθε ένα συγκεκριμένο αριθμό γραμμών να σταματά το - * τύπωμα και να περιμένει να πατηθεί <Enter> από τον χρήστη. - */ -void PrintMatrix (int *Mat, int N) -{ - int i; - for (i = 0; i < N; i++) - printf ("Element %4d Value: %5d\n", i + 1, Mat[i]); -} - -/** - * Συγκρίνει τα περιεχόμενα 2 πινάκων και επιστρέφει true αν όλα τα στοιχεία τους είναι ίσα ένα προς ένα. - * Δοκιμάστε την με και χωρίς το else. - */ -int CompareMatrices (int *M1, int M2[], int S) -{ - int i; - for (i = 0; i < S; i++) - if (M1[i] != *(M2 + i)) - return 0; - //else - return 1; -} - -/** - * Επιστρέφει ένα τυχαίο αριθμό στο διάστημα [L1...L2]. - * Το L2 πρέπει να είναι μεγαλύτερο ή ίσο του L1 με ευθύνη του προγραμματιστή - */ -int GetRandom (int L1, int L2) -{ - return random () % (L2 - L1 + 1) + L1; -} - -/** - * Γεμίζει έναν πίνακα ακεραίων με τυχαίες τιμές σε συγκεκριμένα όρια - */ -void RandomFill (int *P, int N, int O1, int O2) -{ - int i; - for (i = 0; i < N; P[i++] = GetRandom (O1, O2)); -} - -/** - * Ελέγχει αν είνας πίνακας είναι ταξινομημένος. - * Δουλεύει αν ο πίνακας έχει ένα μόνο ή κανένα στοιχείο; - */ -int IsSorted (int *P, int S) -{ - int i; - for (i = 1; i < S; i++) - if (P[i] < P[i - 1]) - return 0; - return 1; -} - -/** - * Ταξινομεί έναν πίνακα με ένα καθόλου έξυπνο αλγόριθμο και επιστρέφει το πλήθος των επαναλήψεων που πραγματοποιήθηκαν. - * Ο αριθμός που θα επιστρέφεται θα είναι πάντα σωστός; Αν όχι σε ποια περίπτωση και τι μπορεί να γίνει για αυτό; - * Βελτιώστε την απόδοση της συνάρτησης διατηρώντας την βασική ιδέα. - */ -int LudicrousSort (int *Mat, int N) -{ - int C = 0; - int tmp; - int i, j; - while (!IsSorted (Mat, N)) - { - C++; - i = GetRandom (0, N - 1); - j = GetRandom (0, N - 1); - tmp = Mat[i]; - Mat[i] = Mat[j]; - Mat[j] = tmp; - } - return C; -} - -/** - * Τι κάνει αυτή η συνάρτηση; - * Υλοποιείστε την με διαφορετικό τρόπο - */ -void Strange1 (int *P, int S) -{ - int i; - char *p; - p = (char *)P; - for (i = 0; i < S; i++) - { - *p = *p & (unsigned char ) 254; - p += sizeof (int); - } -} - -/* -================================================================================================= -Γράψτε μία συνάρτηση η οποία θα επιστρέφει τους δύο μεγαλύτερους αριθμούς ενός πίνακα σαρώνοντάς -τον μόνο μία φορά. - -Υλοποιείστε μία δική σας συνάρτηση η οποία θα λειτουργεί όπως η "realloc" - -Υλοποιείστε σειριακή και δυαδική αναζήτηση -*/ - - - - - - - - diff --git a/c-programming/5-arrays-pointers-files/examples/Lexico.c b/c-programming/5-arrays-pointers-files/examples/Lexico.c @@ -1,149 +0,0 @@ -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - -int GetSize (void); -void ClearBuf (void); -void RemoveEnter (char *); -char **ReadWords (int); -void PrintWords (char **, int); -void FreeMem (char **, int); -void SortWords (char **, int); -void SortWordsByLength (char **, short int *, int); -short int *CreateLexeisSize (char **, int); -void ShowMemory (char **, int); - -int main (int argc, char **argv) -{ - char **Lexeis; - short int *LexeisSize; - int N; - N = GetSize (); - Lexeis = ReadWords (N); - PrintWords (Lexeis, N); - SortWords (Lexeis, N); - PrintWords (Lexeis, N); - LexeisSize = CreateLexeisSize (Lexeis, N); - SortWordsByLength (Lexeis, LexeisSize, N); - PrintWords (Lexeis, N); - ShowMemory (Lexeis, N); - FreeMem (Lexeis, N); - -} - -int GetSize () -{ - int S; - do - { - printf ("Enter Number of Words: "); - scanf ("%d", &S); - } - while (S < 1); - ClearBuf (); - return S; -} - -void ClearBuf () -{ - char ch; - while (( ch = getc (stdin)) != '\n' && ch != EOF); -} - -void RemoveEnter (char *W) -{ - int i; - for (i = 0; W[i] != 10 && W[i] != 13; i++); - W[i] = 0; -} - -char **ReadWords (int S) -{ - char **Words; - char *Buf; - int i; - Buf = (char *) malloc (201); - Words = (char **) malloc (S * sizeof (char *)); - for (i = 0; i < S; i++) - { - printf ("Enter word %d: ", i + 1); - fgets (Buf, 201, stdin); - RemoveEnter (Buf); - Words[i] = (char *) malloc (strlen (Buf) + 1); - strcpy (Words[i], Buf); - } - free (Buf); - return Words; -} - -void PrintWords (char **Words, int NoW) -{ - int i; - printf (" AA Word Length\n"); - for (i = 0; i < NoW; i++) - printf ("[%3d] %-30s (%2d)\n", i + 1, Words[i], strlen (Words[i])); - printf ("----------------------------------------------------------------------------------\n\n"); -} - -void FreeMem (char **L, int N) -{ - int i; - for (i = 0; i < N; i++) - free (*(L + i)); - free (L); -} - -void SortWords (char **Words, int S) -{ - char *tmp; - int i, j; - for (i = 0; i < S - 1; i++) - for (j = i + 1; j < S; j++) - if (strcmp (Words[i], Words[j]) > 0) - { - tmp = Words[i]; - Words[i] = Words[j]; - Words[j] = tmp; - } -} - -void SortWordsByLength (char **Words, short int *WL, int S) -{ - short int tmp; - char *tmp1; - int i, j; - for (i = 0; i < S - 1; i++) - for (j = i + 1; j < S; j++) - if (WL[i] > WL[j]) - { - tmp = WL[i]; - WL[i] = WL[j]; - WL[j] = tmp; - tmp1 = Words[i]; - Words[i] = Words[j]; - Words[j] = tmp1; - } -} - -short int *CreateLexeisSize (char **Words, int S) -{ - short int *Mat; - int i; - Mat = (short int *) malloc (S * sizeof (short int)); - for (i = 0; i < S; i++) - *(Mat + i) = strlen (*(Words + i)); - return Mat; -} - -void ShowMemory (char **W, int P) -{ - int i; - printf ("The Lexeis pointer Contains: %p\n", W); - printf (" Lexeis+i Lexeis[i] Word\n"); - printf (" --------------\n"); - for (i = 0; i < P; i++) - { - printf (" %10p | %10p | ---> %s\n", W + i, *(W + i), *(W + i)); - printf (" --------------\n"); - } -} diff --git a/c-programming/5-arrays-pointers-files/examples/mystring.c b/c-programming/5-arrays-pointers-files/examples/mystring.c @@ -1,103 +0,0 @@ -#include <stdio.h> -#include <string.h> - -int mystrcmp (char *, char *); -int mystrlen (char *); -void mystrcpy (char *, char *); -char *mystrcat (char *, char *); - -int main (int argc, char **argv) -{ - char Str1[50] = "Thanasis"; - char Str2[50] = "Maria"; - char Str3[50] = "MariaP"; - char Str4[50] = ""; - - printf ("Name 1 : %s\n", Str1); - printf ("Name 2 : %s\n", Str2); - printf ("Name 3 : %s\n", Str3); - printf ("Name 4 : %s\n", Str4); - - printf ("\n"); - printf ("Compare Name 1 with Name 2: %d \n", mystrcmp (Str1, Str2)); - printf ("Compare Name 2 with Name 1: %d \n", mystrcmp (Str2, Str1)); - printf ("Compare Name 1 with Name 1: %d \n", mystrcmp (Str1, Str1)); - printf ("Compare Name 2 with Name 3: %d \n", mystrcmp (Str2, Str3)); - printf ("Compare Name 3 with Name 2: %d \n", mystrcmp (Str3, Str2)); - - printf ("\n"); - printf ("Length of Name 1 : %d\n", mystrlen (Str1)); - printf ("Length of Name 2 : %d\n", mystrlen (Str2)); - printf ("Length of Null String : %d\n", mystrlen ("")); - - printf ("\n"); - mystrcpy (Str4, Str1); - printf ("Name 4: %s is copy of Name 1: %s\n", Str4, Str1); - - printf ("\n"); - mystrcat (Str4, Str2); - printf ("New Name 4: %s\n", Str4); - - -} - -/* - * Υλοποίηση της "strcmp" - * Αυτό που επιστρέφει είναι το ίδιο / συμβατό με αυτό που επιστρέφει η έτοιμη συνάρτηση; - * Υλοποιείστε την strncmp - */ - -int mystrcmp (char *s1, char *s2) -{ - int i; - for (i = 0; s1[i] == s2[i] && s1[i] != 0; i++); - return s1[i] - s2[i]; -} - -/* - * Υλοποίηση της "strlen". - * Ξεκαθαρείστε το νόημα της συνθήκης, συντακτικά και λογικά - */ -int mystrlen (char *s) -{ - int i; - for (i = 0; s[i]; i++); - return i; -} - -/* - * Υλοποίηση της "strcpy" - * Είναι κατανοητό πως δουλεύει; - * Σε τι διαφέρει από την έτοιμη συνάρτηση; Διορθώστε την ώστε να πληροί τις προδιαγραφές της έτοιμης συνάρτησης. - * Υλοποιείστε την με έναν... πιο αλγοριθμικό τρόπο. - * Υλοποιείστε την strncpy - */ -void mystrcpy (char *d, char *s) -{ - int i = 0; - while (d[i]=s[i++]); -} - -/* - * Υλοποίηση της "strcat" - * Υλοποιείστε την χωρίς την κλήση άλλης συνάρτησης. - * Υλοποιείστε την strncat - */ -char *mystrcat (char *d, char *s) -{ - char *tmp; - tmp = d; - while (*tmp) - tmp++; - // while (*(tmp++)); // Γιατί όχι μόνο αυτό; - mystrcpy (tmp, s); - return d; -} - -/* - * Υλοποιείστε τις παρακάτω συναρτήσεις: - * -strdup - * -strlwr - * -strupr - */ - diff --git a/c-programming/5-arrays-pointers-files/fcombinations/bin/fcombs b/c-programming/5-arrays-pointers-files/fcombinations/bin/fcombs Binary files differ. diff --git a/c-programming/5-arrays-pointers-files/fcombinations/obj/arrhandler.o b/c-programming/5-arrays-pointers-files/fcombinations/obj/arrhandler.o Binary files differ. diff --git a/c-programming/5-arrays-pointers-files/fcombinations/obj/fcombinations.o b/c-programming/5-arrays-pointers-files/fcombinations/obj/fcombinations.o Binary files differ. diff --git a/c-programming/5-arrays-pointers-files/fcombinations/obj/main.o b/c-programming/5-arrays-pointers-files/fcombinations/obj/main.o Binary files differ. diff --git a/c-programming/5-arrays-pointers-files/kcombinations/bin/combs b/c-programming/5-arrays-pointers-files/kcombinations/bin/combs Binary files differ. diff --git a/c-programming/5-arrays-pointers-files/kcombinations/bin/kcombs b/c-programming/5-arrays-pointers-files/kcombinations/bin/kcombs Binary files differ. diff --git a/c-programming/5-arrays-pointers-files/kcombinations/obj/arrhandler.o b/c-programming/5-arrays-pointers-files/kcombinations/obj/arrhandler.o Binary files differ. diff --git a/c-programming/5-arrays-pointers-files/kcombinations/obj/kcombinations.o b/c-programming/5-arrays-pointers-files/kcombinations/obj/kcombinations.o Binary files differ. diff --git a/c-programming/5-arrays-pointers-files/kcombinations/obj/main.o b/c-programming/5-arrays-pointers-files/kcombinations/obj/main.o Binary files differ. diff --git a/c-programming/5-arrays-pointers-files/minecurses/bin/minecurses b/c-programming/5-arrays-pointers-files/minecurses/bin/minecurses Binary files differ. diff --git a/c-programming/5-arrays-pointers-files/minecurses/obj/audio.o b/c-programming/5-arrays-pointers-files/minecurses/obj/audio.o Binary files differ. diff --git a/c-programming/5-arrays-pointers-files/minecurses/obj/gameplay.o b/c-programming/5-arrays-pointers-files/minecurses/obj/gameplay.o Binary files differ. diff --git a/c-programming/5-arrays-pointers-files/minecurses/obj/main.o b/c-programming/5-arrays-pointers-files/minecurses/obj/main.o Binary files differ. diff --git a/c-programming/5-arrays-pointers-files/minecurses/obj/minesweeper.o b/c-programming/5-arrays-pointers-files/minecurses/obj/minesweeper.o Binary files differ. diff --git a/c-programming/5-arrays-pointers-files/minecurses/obj/navigation.o b/c-programming/5-arrays-pointers-files/minecurses/obj/navigation.o Binary files differ. diff --git a/c-programming/5-arrays-pointers-files/minecurses/obj/outputs.o b/c-programming/5-arrays-pointers-files/minecurses/obj/outputs.o Binary files differ. diff --git a/c-programming/5-arrays-pointers-files/minecurses/obj/settings.o b/c-programming/5-arrays-pointers-files/minecurses/obj/settings.o Binary files differ. diff --git a/c-programming/5-arrays-pointers-files/minecurses/obj/wins.o b/c-programming/5-arrays-pointers-files/minecurses/obj/wins.o Binary files differ. diff --git a/cpp-oop/1-fromctocpp/Ex1.cpp b/cpp-oop/1-fromctocpp/Ex1.cpp @@ -1,112 +0,0 @@ -#include <iostream> -#include <string> - - -struct STUD -{ - int AM; - std::string Name; - int Semester; -}; - -using namespace std; - -STUD * InitStuds (); -void swap (int &, int &); -void swap (STUD &, STUD &); -void ShowStuds (const STUD *, const int); -void SortStuds (STUD *, int); -STUD& GetStudBySemester (STUD[], const int, const int); -int Cube (int len, int=2, int=1); - - - - -int main (int argc, char **argv) -{ - int a = 20; - int b = 30; - swap (a, b); - cout << "a = " << a << ", b = " << b << endl <<endl; - - STUD *st = InitStuds (); - ShowStuds (st, 3); - SortStuds (st, 3); - ShowStuds (st, 3); - STUD &R = GetStudBySemester (st, 3, 5); - R.Name = "Changed"; - ShowStuds (st, 3); - delete[] st; - - cout << Cube (2, 3, 4) << endl; - cout << Cube (2, 3) << endl; - cout << Cube (2) << endl; -} - -//Η γνωστή συνάρτηση swap σε cpp έκδοση με references. -void swap (int &i1, int &i2) -{ - int tmp; - tmp = i1; - i1 = i2; - i2 =tmp; -} - -//Η συνάρτηση swap υπερφορτωμένη για struct STUD -void swap (STUD &i1, STUD &i2) -{ - STUD tmp; - tmp = i1; - i1 = i2; - i2 =tmp; -} - -//Δημιουργεί έναν δυναμικό πίνακα 3 θέσεων τύπου STUD και τον αρχικοποιεί "καρφωτά" -STUD * InitStuds () -{ - STUD *tmp = new STUD [3]; - tmp[0].AM = 456; - tmp[0].Name = "Αντωνίου"; - tmp[0].Semester = 2; - tmp[1].AM = 123; - tmp[1].Name = "Βασιλείου"; - tmp[1].Semester = 1; - tmp[2].AM = 789; - tmp[2].Name = "Γεωργίου"; - tmp[2].Semester = 5; - return tmp; -} - -//Τυπώνει τα στοιχεία του πίνακα τύπου STUD -void ShowStuds (const STUD *S, const int N) -{ - //N++; - for (int i = 0; i < N; i++) - cout << S[i].AM << " " << S[i].Name << " " << S[i].Semester << endl; - cout << endl; -} - -//Ταξινομεί τον πίνακα τύπου STUD -void SortStuds (STUD *S, int N) -{ - for (int i = 0; i < N - 1; i++) - for (int j = i + 1; j < N; j++) - if (S[i].AM > S[j].AM) - swap (S[i], S[j]); -} - -//Παράδειγμα συνάρτησης που επιστρέφει αναφορά -STUD& GetStudBySemester (STUD D[], const int S, const int Semester) -{ - int i; - for (i = 0; i < S; i++) - if (D[i].Semester == Semester) - return D[i]; - return D[0]; -} - -int Cube (int len, int wid, int hei) -{ - return len * wid * hei; -} - diff --git a/cpp-oop/2-classes/BigIntv1.cpp b/cpp-oop/2-classes/BigIntv1.cpp @@ -1,116 +0,0 @@ -#include <stdio.h> -#include <string.h> -#include <string> -#include <new> - -using namespace std; - -class BigInt -{ - int size; - char *numb; -public: - BigInt (); - BigInt (const char *); - BigInt (int); - BigInt (const BigInt &); - ~BigInt (); - void Print () const; - -}; - -BigInt::BigInt () -{ - size = 1; - numb = new char [1]; - numb[0] = 0; -} - -BigInt::BigInt (const char *s) -{ - printf("constructing string %s \n",s); - int i; - int l = strlen(s); - if (l) - { - numb = new char [l]; - for(i = 0; i < l; i++) - numb[i] = s[l - 1 - i] - 48; - size = l; - } -} - -BigInt::BigInt (int nu) -{ - printf("constructing int %d\n",nu); - char *s; - s = new char [12]; - sprintf (s, "%d", nu); - int i; - int l = strlen(s); - if (l) - { - numb = new char [l]; - for(i = 0; i < l; i++) - numb[i] = s[l - 1 - i] - 48; - size = l; - } - delete[] s; -} - -BigInt::BigInt (const BigInt &x) //Σβήστε το const (εδώ και στο πρότυπο της κλάσης) και δείτε τι συμβαίνει!!! -{ - printf("Copy constructing\n"); - size = x.size; - numb = new char [size]; - memcpy (numb, x.numb, size); -} - -BigInt::~BigInt () -{ - printf("deleting "); - Print(); - delete [] numb; -} - -void BigInt::Print () const -{ - int i; - printf ("*"); - for ( i = size - 1; i >= 0; i--) - printf ("%c", numb[i] + 48); - printf ("*\n"); -} - - -void XXX (BigInt x) //Τι συμβαίνει αν μπει αναφορά; Πως είναι καλύτερα; -{ - //Some functionality - x.Print (); -} - -int main() -{ - BigInt a; - a.Print (); - BigInt b = "123456789987654321"; - b.Print (); - BigInt c = 100; - c.Print (); - BigInt d (123); //Είναι ΑΚΡΙΒΩΣ το ίδιο με το προηγούμενο;; Σε τι θα μπορούσε να διαφέρει;;; - d.Print (); - BigInt e = b; - e.Print (); - BigInt f(b); - f.Print (); - printf ("================================\n"); - XXX (b); //Τι αλλάζει αν υπάρχει και όταν δεν υπάρχει αντιγραφέας; - b.Print (); - - XXX (25); - - //string q = "123"; - //BigInt z = q; - //z.Print (); -} - diff --git a/cpp-oop/3-operoverloading/BigIntv3.cpp b/cpp-oop/3-operoverloading/BigIntv3.cpp @@ -1,444 +0,0 @@ -#include <stdio.h> -#include <string.h> -#include <string> -#include <new> -#include <iostream> - -using namespace std; - -class BigInt -{ -public: - static int MaxSize; - static char *MaxNumb; - static void PrintMax (); -private: - int size; - char *numb; -public: - BigInt (); - BigInt (const char *); - BigInt (int); - BigInt (const BigInt &); - ~BigInt (); - void Print () const; - void operator+= (const BigInt &); - void operator+= (int ); - BigInt operator+ (BigInt &); - BigInt operator+ (const char *); - BigInt operator+ (const int); - BigInt operator* (const BigInt &); - BigInt operator= (const BigInt &); - BigInt operator++ (); - BigInt operator++ (int); - BigInt operator-- (); - BigInt operator-- (int); - int operator== (const BigInt &); - int operator!= (const BigInt &); - -}; - -class LibExc -{ -public: - int ErrCode; - string ErrMess; - LibExc (int C, string M) - { - ErrCode = C; - ErrMess = M; - } -}; - -int BigInt::MaxSize = 0; - -char *BigInt::MaxNumb = NULL; - -void BigInt::PrintMax () -{ - int i; - if (MaxNumb) - { - printf ("*"); - for ( i = MaxSize - 1; i >= 0; i--) - printf ("%c", MaxNumb[i] + 48); - printf ("*\n"); - } -} - -BigInt::BigInt () -{ - size = 1; - numb = new (nothrow) char [1]; - if (numb == NULL) - throw (1); - numb[0] = 0; -} - -BigInt::BigInt (const char *s) -{ - //printf("constructing string %s \n",s); - int i; - int l = strlen(s); - for (i = 0; i <l; i++) - { - if (s[i] < '0' || s[i] > '9') - throw (2); - } - if (l) - { - numb = new (nothrow) char [l]; - if (!numb) - throw (1); - for(i = 0; i < l; i++) - numb[i] = s[l - 1 - i] - 48; - size = l; - } - if (l > BigInt::MaxSize) - { - MaxSize = l; - MaxNumb = numb; - } -} - -BigInt::BigInt (int nu) -{ - //printf("constructing int %d\n",nu); - char *s; - s = new char [12]; - sprintf (s, "%d", nu); - int i; - int l = strlen(s); - if (l) - { - numb = new (nothrow) char [l]; - if (numb == NULL) - throw (1); - for(i = 0; i < l; i++) - numb[i] = s[l - 1 - i] - 48; - size = l; - } - delete[] s; - if (l > BigInt::MaxSize) - { - MaxSize = l; - MaxNumb = numb; - } -} - -BigInt::BigInt (const BigInt &x) //Σβήστε το const και δείτε τι συμβαίνει!!! -{ - //printf("Copy constructing\n"); - size = x.size; - numb = new (nothrow) char [size]; - if (numb == NULL) - throw (1); - memcpy (numb, x.numb, size); -} - -BigInt::~BigInt () -{ - if (numb == MaxNumb) - MaxNumb = NULL; - delete [] numb; -} - -void BigInt::Print () const -{ - int i; - printf ("*"); - for ( i = size - 1; i >= 0; i--) - printf ("%c", numb[i] + 48); - printf ("*\n"); -} - -void BigInt::operator+= (const BigInt &x) -{ - int S1, S2, m, Kr = 0; - int i; - - for(i = 0; i < size; i++) - { - numb[i] += x.numb[i] + Kr; - if (numb[i] > 10) - { - numb[i] -= 10; - Kr = 1; - } - else - Kr = 0; - } -} - -void BigInt::operator+= (int i) -{ - printf ("I will not add %d\n", i); -} - -BigInt BigInt::operator+ (BigInt &x) -{ - int i, j, s, Kr = 0, r, D1, D2, D; - s = (size > x.size) ? size : x.size; - char buf[s + 1]; - char buf1[s + 2]; - for (i = 0; i < s; i++) - { - D1 = (i < size) ? numb[i] : 0; - D2 = (i < x.size) ? x.numb[i] : 0; - D = D1 + D2 + Kr; - Kr = 0; - if (D > 9) - { - D -= 10; - Kr = 1; - } - buf[i] = D; - } - if (Kr) - buf[i] = Kr; - else - i--; - for (j = 0; i >= 0; j++, i--) - buf1[j] = buf[i] + 48; - buf1[j] = '\0'; - BigInt Q(buf1); - return Q; -} - -BigInt BigInt::operator+ (const char *s) -{ - BigInt Tmp(s); - return *this + Tmp; -} - -BigInt BigInt::operator+ (int s) -{ - BigInt Tmp(s); - return *this + Tmp; -} - -BigInt BigInt::operator= (const BigInt &x) //Σβήστε το const και δείτε τι συμβαίνει -{ - delete[] numb; - size = x.size; - numb = new (nothrow) char [size]; - if (numb == NULL) - throw (1); - memcpy (numb, x.numb, size); - return *this; -} - -BigInt BigInt::operator++() -{ - int i; - numb[0]++; - for(i = 0; i < size - 1; i++) - if (numb[i] == 10) - { - numb[i] = 0; - numb[i + 1]++; - } - if (numb[size - 1] == 10) - { - numb[size - 1] = 0; - char *buf1 = new (nothrow) char[++size]; - if (numb == NULL) - throw (1); - memcpy (buf1, numb, size - 1); - buf1[size - 1] = 1; - delete [] numb; - numb = buf1; - } - return *this; -} - -BigInt BigInt::operator++ (int ) -{ - int i; - BigInt tmp = *this; - numb[0]++; - for(i = 0; i < size - 1; i++) - if (numb[i] == 10) - { - numb[i] = 0; - numb[i + 1]++; - } - if (numb[size - 1] == 10) - { - numb[size - 1] = 0; - char *buf1 = new (nothrow) char[++size]; - if (numb == NULL) - throw (1); - memcpy (buf1, numb, size - 1); - buf1[size - 1] = 1; - delete [] numb; - numb = buf1; - } - return tmp; -} - -BigInt BigInt::operator* (const BigInt &x) -{ - BigInt res = "0"; - BigInt t = x; - BigInt z = 0; - while (t != z) - { - res = res + *this; -// printf("----"); -// res.Print(); - --t; - } - return res; -} - - -BigInt BigInt::operator-- () -{ - int i; - if ((numb[0] == 0) && (size == 1)) - return *this; - numb[0]--; - for(i = 0 ; i < size; i++) - { - if (numb[i] == -1) - { - numb[i] = 9; - numb[i + 1]--; - } - } - if (numb[size - 1] == 0 && size > 1) - { - char *buf1 = new char[--size]; - memcpy (buf1, numb, size); - delete [] numb; - numb = buf1; - } - - return *this; -} - -BigInt BigInt::operator--(int) -{ - BigInt tmp = *this; - --*this; - return tmp; -} - -int BigInt::operator== (const BigInt &x) -{ - if (size != x.size) - return 0; - for(int i = 0; i < size; i++) - if (numb[i] != x.numb[i]) - return 0; - return 1; -} - -int BigInt::operator != (const BigInt &x) -{ - if (*this == x) - return 0; - return 1; -} - -BigInt BigProduct (BigInt Num) -{ - Num++; - BigInt I = 1; - BigInt P = 1; - while (I != Num) - { - P = P * I; - I = I + 1; - } - return P; -} - -BigInt Power (char *B, int E) -{ - if (E < 0) - { - string m("Invalid Expmponent"); - LibExc e(2, m); - throw e; - } - try - { - BigInt Ex(E); - BigInt Ba(B); - BigInt Res = 1; - BigInt I = 0; - while (I != Ex) - { - Res = Res * Ba; - I++; - //Res.Print (); - //cout << endl; - } - return Res; - } - catch (int e) - { - if (e == 1) - throw; - if (e == 2) - throw LibExc (1, *(new string ("Invalid Base:"))); - } -} - -main () -{ - int i; - char N[100]; - bool cont; - do - { - cont = false; - try - { - cout << "Enter Number to find Product:"; - cin >> N; - BigInt x; - BigInt k(N); - x = BigProduct (k); - x.Print(); - } - catch (int e) - { - if (e == 1) - { - cout << "Memory Error: " << BigInt::MaxNumb; - cout << BigInt::MaxSize << " "; BigInt::PrintMax (); - } - if (e == 2) - { - cout << "Initialization Error" << endl; - cont = true; - } - } - } - while (cont); - cout << "========================================================================" << endl; - try - { - char B[100]; - int E; - cout << "Base: "; - cin >> B; - cout << "Exponent: "; - cin >> E; - BigInt a = Power (B, E); - a.Print (); - } - catch (int e) - { - cout << "Memory Error: " << BigInt::MaxNumb; - cout << BigInt::MaxSize << " "; BigInt::PrintMax (); - } - catch (LibExc e) - { - cout << "Parameter Error" << endl; - cout << e.ErrCode << " " << e.ErrMess << endl; - } -} diff --git a/cpp-oop/3-operoverloading/bin/operoverloading b/cpp-oop/3-operoverloading/bin/operoverloading Binary files differ. diff --git a/cpp-oop/3-operoverloading/obj/course.o b/cpp-oop/3-operoverloading/obj/course.o Binary files differ. diff --git a/cpp-oop/3-operoverloading/obj/main.o b/cpp-oop/3-operoverloading/obj/main.o Binary files differ. diff --git a/cpp-oop/3-operoverloading/obj/student.o b/cpp-oop/3-operoverloading/obj/student.o Binary files differ. diff --git a/cpp-oop/3-operoverloading/obj/subject.o b/cpp-oop/3-operoverloading/obj/subject.o Binary files differ. diff --git a/cpp-oop/4-inheritance/bin/inheritance b/cpp-oop/4-inheritance/bin/inheritance Binary files differ. diff --git a/cpp-oop/4-inheritance/obj/app.o b/cpp-oop/4-inheritance/obj/app.o Binary files differ. diff --git a/cpp-oop/4-inheritance/obj/appsystem.o b/cpp-oop/4-inheritance/obj/appsystem.o Binary files differ. diff --git a/cpp-oop/4-inheritance/obj/errlog.o b/cpp-oop/4-inheritance/obj/errlog.o Binary files differ. diff --git a/cpp-oop/4-inheritance/obj/game.o b/cpp-oop/4-inheritance/obj/game.o Binary files differ. diff --git a/cpp-oop/4-inheritance/obj/main.o b/cpp-oop/4-inheritance/obj/main.o Binary files differ. diff --git a/cpp-oop/4-inheritance/obj/manufacturer.o b/cpp-oop/4-inheritance/obj/manufacturer.o Binary files differ. diff --git a/cpp-oop/4-inheritance/obj/office.o b/cpp-oop/4-inheritance/obj/office.o Binary files differ. diff --git a/cpp-oop/4-inheritance/obj/review.o b/cpp-oop/4-inheritance/obj/review.o Binary files differ. diff --git a/cpp-oop/5-spreadsheets/bin/spreadsheets b/cpp-oop/5-spreadsheets/bin/spreadsheets Binary files differ. diff --git a/cpp-oop/5-spreadsheets/obj/datahandler.o b/cpp-oop/5-spreadsheets/obj/datahandler.o Binary files differ. diff --git a/cpp-oop/5-spreadsheets/obj/errlog.o b/cpp-oop/5-spreadsheets/obj/errlog.o Binary files differ. diff --git a/cpp-oop/5-spreadsheets/obj/grade.o b/cpp-oop/5-spreadsheets/obj/grade.o Binary files differ. diff --git a/cpp-oop/5-spreadsheets/obj/grades.o b/cpp-oop/5-spreadsheets/obj/grades.o Binary files differ. diff --git a/cpp-oop/5-spreadsheets/obj/main.o b/cpp-oop/5-spreadsheets/obj/main.o Binary files differ. diff --git a/cpp-oop/5-spreadsheets/obj/report.o b/cpp-oop/5-spreadsheets/obj/report.o Binary files differ. diff --git a/cpp-oop/5-spreadsheets/obj/xstring.o b/cpp-oop/5-spreadsheets/obj/xstring.o Binary files differ.