From 2437a3497a177599aaa145d801160a1d7c1a1452 Mon Sep 17 00:00:00 2001 From: GGdudesGG Date: Wed, 13 Jan 2016 23:48:59 +0200 Subject: [PATCH 1/5] task1.c disappeared --- 2015-2016/G/07/big_homework/task2.c | 33 +++++++++++++++++++++++++ 2015-2016/G/07/big_homework/task3.c | 38 +++++++++++++++++++++++++++++ 2 files changed, 71 insertions(+) create mode 100644 2015-2016/G/07/big_homework/task2.c create mode 100644 2015-2016/G/07/big_homework/task3.c diff --git a/2015-2016/G/07/big_homework/task2.c b/2015-2016/G/07/big_homework/task2.c new file mode 100644 index 00000000..04c331fd --- /dev/null +++ b/2015-2016/G/07/big_homework/task2.c @@ -0,0 +1,33 @@ +#include +#include +#include + + +int main() +{ + int i; + int sum = 0; + char msg[200]; + int box ; + scanf("%[^\n]s", msg); + box = strlen(msg); + for (i = 0; i < box; i++) + { + if(msg[i] == 'a'||msg[i] == 'd'||msg[i] == 'g'||msg[i] == 'j'||msg[i] == 'm'||msg[i] == 'p'||msg[i] == 't'||msg[i] == 'w'||msg[i] == ' '){ + sum = sum + 1; + } + if(msg[i] == 'b'||msg[i] == 'e'||msg[i] == 'h'||msg[i] == 'k'||msg[i] == 'n'||msg[i] == 'q'||msg[i] == 'u'||msg[i] == 'x'){ + sum = sum + 2; + } + if(msg[i] == 'c'||msg[i] == 'f'||msg[i] == 'i'||msg[i] == 'l'||msg[i] == 'o'||msg[i] == 'r'||msg[i] == 'v'||msg[i] == 'y'){ + sum = sum + 3; + } + if (msg[i] == 'z'||msg[i] == 's') + { + sum = sum + 4; + } + } + + printf("%d", sum); + return 0; +} \ No newline at end of file diff --git a/2015-2016/G/07/big_homework/task3.c b/2015-2016/G/07/big_homework/task3.c new file mode 100644 index 00000000..65b5086c --- /dev/null +++ b/2015-2016/G/07/big_homework/task3.c @@ -0,0 +1,38 @@ +#include + +int main() +{ + int raindeers, i, a, j; + int num[200]; + + printf("Incert the number of the raindeers.\n"); + scanf("%d",&raindeers); + while(raindeers % 2 == 0){ + printf("Incert correct number of raindeers.\n"); + scanf("%d",&raindeers); + } + for (i = 0; i < raindeers; ++i) + { + scanf("%d",&num[i]); + } + + for (i = 0; i < raindeers; ++i) + { + for (j = 0; j < raindeers; ++j) + { + if(num[i] == num[j]){ + a = 1; + } + else{ + a = 0; + } + } + if(a == 0){ + printf("%d\n", num[i]); + break; + } + } + + return 0; +} + From b9db0855ac6c7bc81e689aaf55216b2b2c88d9d8 Mon Sep 17 00:00:00 2001 From: GGdudesGG Date: Mon, 18 Jan 2016 19:52:02 +0200 Subject: [PATCH 2/5] renamed --- 2015-2016/G/07/Homework-08/task2.c | 33 ++++++++++++++++++++++++++ 2015-2016/G/07/Homework-08/task3.c | 38 ++++++++++++++++++++++++++++++ 2 files changed, 71 insertions(+) create mode 100644 2015-2016/G/07/Homework-08/task2.c create mode 100644 2015-2016/G/07/Homework-08/task3.c diff --git a/2015-2016/G/07/Homework-08/task2.c b/2015-2016/G/07/Homework-08/task2.c new file mode 100644 index 00000000..04c331fd --- /dev/null +++ b/2015-2016/G/07/Homework-08/task2.c @@ -0,0 +1,33 @@ +#include +#include +#include + + +int main() +{ + int i; + int sum = 0; + char msg[200]; + int box ; + scanf("%[^\n]s", msg); + box = strlen(msg); + for (i = 0; i < box; i++) + { + if(msg[i] == 'a'||msg[i] == 'd'||msg[i] == 'g'||msg[i] == 'j'||msg[i] == 'm'||msg[i] == 'p'||msg[i] == 't'||msg[i] == 'w'||msg[i] == ' '){ + sum = sum + 1; + } + if(msg[i] == 'b'||msg[i] == 'e'||msg[i] == 'h'||msg[i] == 'k'||msg[i] == 'n'||msg[i] == 'q'||msg[i] == 'u'||msg[i] == 'x'){ + sum = sum + 2; + } + if(msg[i] == 'c'||msg[i] == 'f'||msg[i] == 'i'||msg[i] == 'l'||msg[i] == 'o'||msg[i] == 'r'||msg[i] == 'v'||msg[i] == 'y'){ + sum = sum + 3; + } + if (msg[i] == 'z'||msg[i] == 's') + { + sum = sum + 4; + } + } + + printf("%d", sum); + return 0; +} \ No newline at end of file diff --git a/2015-2016/G/07/Homework-08/task3.c b/2015-2016/G/07/Homework-08/task3.c new file mode 100644 index 00000000..65b5086c --- /dev/null +++ b/2015-2016/G/07/Homework-08/task3.c @@ -0,0 +1,38 @@ +#include + +int main() +{ + int raindeers, i, a, j; + int num[200]; + + printf("Incert the number of the raindeers.\n"); + scanf("%d",&raindeers); + while(raindeers % 2 == 0){ + printf("Incert correct number of raindeers.\n"); + scanf("%d",&raindeers); + } + for (i = 0; i < raindeers; ++i) + { + scanf("%d",&num[i]); + } + + for (i = 0; i < raindeers; ++i) + { + for (j = 0; j < raindeers; ++j) + { + if(num[i] == num[j]){ + a = 1; + } + else{ + a = 0; + } + } + if(a == 0){ + printf("%d\n", num[i]); + break; + } + } + + return 0; +} + From e8d14f6fe641d3dbc1e3d3cc339da295c0758b22 Mon Sep 17 00:00:00 2001 From: GGdudesGG Date: Fri, 22 Jan 2016 19:36:22 +0200 Subject: [PATCH 3/5] New homework --- 2015-2016/G/07/Homework-09/task1.c | 34 +++++++++++++++++++++++ 2015-2016/G/07/Homework-09/task2.c | 44 ++++++++++++++++++++++++++++++ 2 files changed, 78 insertions(+) create mode 100644 2015-2016/G/07/Homework-09/task1.c create mode 100644 2015-2016/G/07/Homework-09/task2.c diff --git a/2015-2016/G/07/Homework-09/task1.c b/2015-2016/G/07/Homework-09/task1.c new file mode 100644 index 00000000..fcd024b7 --- /dev/null +++ b/2015-2016/G/07/Homework-09/task1.c @@ -0,0 +1,34 @@ +#include + +int main() +{ + int a, b, i, helper[32]; + scanf("%d", &a); + scanf("%d", &b); + + for(i = 1; i > 0;){ + if(a < 0 || a > 7) + { + printf("enter a valid a\n"); + scanf("%d", &a); + } + } + for(i = 1; i > 0;){ + if(b < 0 || b > 200) + { + printf("enter a valid b\n"); + scanf("%d", &b); + } + } + + for(i = 32; i != 0 ; i--) + { + helper[i] = b % 2; + b /= 2; + } + + printf("%d\n", helper[a]); + + return 0; +} + diff --git a/2015-2016/G/07/Homework-09/task2.c b/2015-2016/G/07/Homework-09/task2.c new file mode 100644 index 00000000..22674f47 --- /dev/null +++ b/2015-2016/G/07/Homework-09/task2.c @@ -0,0 +1,44 @@ +#include + +int main() +{ + int n, v, p, i, help[32], sum, j, a; + scanf("%d", &n); + scanf("%d", &v); + for(i = 1; i > 0;){ + if(v != 0 && v != 1) + { + printf("enter a valid V\n"); + scanf("%d", &v); + } + } + scanf("%d", &p); + for(i = 1; i > 0;){ + if(p < 0 || p > 7) + { + printf("enter a valid P\n"); + scanf("%d", &p); + } + } + for(i = 32; i != 0 ; i--) + { + help[i] = n % 2; + n /= 2; + } + help[p] = v; + sum = 0; + j = 32; + for (i = 32; i < 0; --i) + { + a = 1; + while(j > i) + { + a = 2 * a; + j--; + } + sum = a * help[i] + sum; + } + printf("%d\n", sum); + + return 0; +} \ No newline at end of file From 901aacb95d7718e0b563e47a18ba7a0bc3809c03 Mon Sep 17 00:00:00 2001 From: GGdudesGG Date: Wed, 16 Mar 2016 18:49:55 +0200 Subject: [PATCH 4/5] My new homework --- 2015-2016/G/07/02/task1.c | 38 +++++++++++++++++++++++++++++++++++++ 2015-2016/G/07/02/task2.c | 37 ++++++++++++++++++++++++++++++++++++ 2015-2016/G/07/02/task3.c | 40 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 115 insertions(+) create mode 100644 2015-2016/G/07/02/task1.c create mode 100644 2015-2016/G/07/02/task2.c create mode 100644 2015-2016/G/07/02/task3.c diff --git a/2015-2016/G/07/02/task1.c b/2015-2016/G/07/02/task1.c new file mode 100644 index 00000000..65163fc0 --- /dev/null +++ b/2015-2016/G/07/02/task1.c @@ -0,0 +1,38 @@ +#include + +void minmax(int *, int, int *, int *); + +int main() +{ + int arr[500], size, min, max, counter; + int sum; + + scanf("%d", &size); + if(size > 0 && size < 500){ + for(counter = 0; counter < size; counter++){ + scanf("%d", &arr[counter]); + } + } + + minmax (arr, size, &min, &max); + + sum = max + min; + + printf("%d\n", sum); + + return 0; +} + +void minmax(int *arr, int size, int *min, int *max) +{ + int i; + + for(i = 0; i < size; i++){ + if(arr[i] > *max){ + *max = arr[i]; + } + if(arr[i] < *min){ + *min = arr[i]; + } + } +} \ No newline at end of file diff --git a/2015-2016/G/07/02/task2.c b/2015-2016/G/07/02/task2.c new file mode 100644 index 00000000..ab65a1fa --- /dev/null +++ b/2015-2016/G/07/02/task2.c @@ -0,0 +1,37 @@ +#include +#include + +char* find(char *, char); + +int main() +{ + char haystack[400], needle; + char *i = 0; + + scanf("%[^\n]s",haystack); + getchar(); + scanf("%c",&needle); + + if(find(haystack ,needle) == NULL){ + printf("-1\n"); + } + else{ + i = find(haystack ,needle); + printf("%d\n",(int)(i - haystack)); + } + + return 0; +} + +char* find(char *haystack, char needle) +{ + int counter = 0; + + while(haystack[counter] != '\0'){ + if(haystack[counter] == needle){ + return &haystack[counter]; + } + counter ++; + } + return NULL; +} diff --git a/2015-2016/G/07/02/task3.c b/2015-2016/G/07/02/task3.c new file mode 100644 index 00000000..de71596f --- /dev/null +++ b/2015-2016/G/07/02/task3.c @@ -0,0 +1,40 @@ +#include +#include + +char* find(char *, char); +int main() +{ + char haystack[400]; + char needle; + char *index_holder = 0; + + scanf("%[^\n]s",haystack); + getchar(); + scanf("%c",&needle); + + if(find(haystack ,needle) == NULL) + { + printf("-1\n"); + } + else + { + index_holder = find(haystack ,needle); + printf("%d\n",(int)(index_holder - haystack)); + } + return 0; +} + +char* find(char *haystack ,char needle) +{ + int counter = 0; + + while(haystack[counter] != '\0') + { + if(haystack[counter] == needle) + { + return &haystack[counter]; + } + counter ++; + } + return NULL; +} \ No newline at end of file From a32db46d05f61aeb866123363aa228bdd54bc44e Mon Sep 17 00:00:00 2001 From: GGdudesGG Date: Wed, 16 Mar 2016 18:58:30 +0200 Subject: [PATCH 5/5] New homework --- 2015-2016/G/07/02/task3.c | 40 --------------------------------------- 1 file changed, 40 deletions(-) delete mode 100644 2015-2016/G/07/02/task3.c diff --git a/2015-2016/G/07/02/task3.c b/2015-2016/G/07/02/task3.c deleted file mode 100644 index de71596f..00000000 --- a/2015-2016/G/07/02/task3.c +++ /dev/null @@ -1,40 +0,0 @@ -#include -#include - -char* find(char *, char); -int main() -{ - char haystack[400]; - char needle; - char *index_holder = 0; - - scanf("%[^\n]s",haystack); - getchar(); - scanf("%c",&needle); - - if(find(haystack ,needle) == NULL) - { - printf("-1\n"); - } - else - { - index_holder = find(haystack ,needle); - printf("%d\n",(int)(index_holder - haystack)); - } - return 0; -} - -char* find(char *haystack ,char needle) -{ - int counter = 0; - - while(haystack[counter] != '\0') - { - if(haystack[counter] == needle) - { - return &haystack[counter]; - } - counter ++; - } - return NULL; -} \ No newline at end of file