From 8ca0a278a9fada98b8cc4bbbcb7850d5c36627a5 Mon Sep 17 00:00:00 2001 From: Goodwitch68 on Acer <56366861+Goodwitch68@users.noreply.github.com> Date: Sat, 12 Oct 2019 07:52:47 +0200 Subject: [PATCH 01/32] finalization --- helloworld/hello.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/helloworld/hello.c b/helloworld/hello.c index 0d5c11e..ad32754 100644 --- a/helloworld/hello.c +++ b/helloworld/hello.c @@ -1,8 +1,8 @@ #include #include int main() { - char first_name[100];/* define first_name */ - char last_name[100];/* define last_name */ + char first_name[100] = "John";/* define first_name */ + char last_name[100] = "Doe"; /* define last_name */ char name[100]; last_name[0] = 'B'; From ebe0fdfeed544b3387b8ce0517eb7e0c01a9ebce Mon Sep 17 00:00:00 2001 From: Goodwitch68 on Acer <56366861+Goodwitch68@users.noreply.github.com> Date: Sat, 12 Oct 2019 07:55:14 +0200 Subject: [PATCH 02/32] final version --- helloworld/elementary_2_3.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 helloworld/elementary_2_3.c diff --git a/helloworld/elementary_2_3.c b/helloworld/elementary_2_3.c new file mode 100644 index 0000000..65cf23c --- /dev/null +++ b/helloworld/elementary_2_3.c @@ -0,0 +1,20 @@ +#include + +int main() { + + char name[100] ;/* define name */ + + setbuf(stdout, NULL); + + printf("Hogy hívnak? "); + scanf("%s", &name); + + if (name[0] == 'A' || name[0] == 'B') { + + setbuf(stdout, NULL); + printf("Üdvözöllek, %s!", name); + } + + + return 0; +} From 0610b5882b5fcc17b10ee8f48c9f41be0d25a511 Mon Sep 17 00:00:00 2001 From: Goodwitch68 on Acer <56366861+Goodwitch68@users.noreply.github.com> Date: Sat, 12 Oct 2019 07:56:39 +0200 Subject: [PATCH 03/32] final version --- helloworld/elementary_4.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 helloworld/elementary_4.c diff --git a/helloworld/elementary_4.c b/helloworld/elementary_4.c new file mode 100644 index 0000000..e80e135 --- /dev/null +++ b/helloworld/elementary_4.c @@ -0,0 +1,21 @@ +#include + +int main() { + + int szam; + int osszeg; + + setbuf(stdout, NULL); + + printf("Írj egy számot: "); + scanf("%d", &szam); + + osszeg = (1+szam)*szam/2; // persze lehetett volna nagyon idétlen ciklussal is megoldani, de ez elegánsabb megoldásnak tűnt :-) + //a + // + setbuf(stdout, NULL); + printf("A számok összege 1-%d-ig:%d", szam, osszeg); + + + return 0; +} From 29c851b73e0456d66af33f33e7bc64ca37bf38e2 Mon Sep 17 00:00:00 2001 From: Goodwitch68 on Acer <56366861+Goodwitch68@users.noreply.github.com> Date: Sat, 12 Oct 2019 08:01:48 +0200 Subject: [PATCH 04/32] =?UTF-8?q?az=20elemetary=204=20=C3=A9s=205=20felada?= =?UTF-8?q?t=20k=C3=A9sz?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- helloworld/elementary_4_5.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 helloworld/elementary_4_5.c diff --git a/helloworld/elementary_4_5.c b/helloworld/elementary_4_5.c new file mode 100644 index 0000000..ae0e677 --- /dev/null +++ b/helloworld/elementary_4_5.c @@ -0,0 +1,32 @@ +#include + +int main() { + + int szam; + int osszeg = 0; + + setbuf(stdout, NULL); + + printf("Írj egy számot: "); + scanf("%d", &szam); + + // és akkor most legyen itt ciklussal, mert erre nincs matematikai képlet, bár gondolkozom rajta :-) + + int i; + for (i=1; i <= szam; i++) + { + if (i % 3 == 0 || i % 5 == 0) { + + osszeg = osszeg + i; + + } + } + + + setbuf(stdout, NULL); + printf("A hárommal vagy öttel osztható számok összege 1-%d-ig:%d", szam, osszeg); + + + return 0; +} +// kész \ No newline at end of file From a95043130d98e900ad227b53198f7128388b7351 Mon Sep 17 00:00:00 2001 From: Goodwitch68 on Acer <56366861+Goodwitch68@users.noreply.github.com> Date: Sat, 12 Oct 2019 08:10:41 +0200 Subject: [PATCH 05/32] change indentation --- helloworld/elementary_2_3.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/helloworld/elementary_2_3.c b/helloworld/elementary_2_3.c index 65cf23c..1aad190 100644 --- a/helloworld/elementary_2_3.c +++ b/helloworld/elementary_2_3.c @@ -11,8 +11,8 @@ int main() { if (name[0] == 'A' || name[0] == 'B') { - setbuf(stdout, NULL); - printf("Üdvözöllek, %s!", name); + setbuf(stdout, NULL); + printf("Üdvözöllek, %s!", name); } From f22c8efea69c28a37ce21c7379c7ee95e50fb065 Mon Sep 17 00:00:00 2001 From: Goodwitch68 on Acer <56366861+Goodwitch68@users.noreply.github.com> Date: Sun, 13 Oct 2019 09:36:07 +0200 Subject: [PATCH 06/32] Committing everything before reinstalling Acer. --- helloworld/elementary_6.c | 46 +++++++++++++++++++++++++++++++++++++++ helloworld/kukutyin.c | 27 +++++++++++++++++++++++ 2 files changed, 73 insertions(+) create mode 100644 helloworld/elementary_6.c create mode 100644 helloworld/kukutyin.c diff --git a/helloworld/elementary_6.c b/helloworld/elementary_6.c new file mode 100644 index 0000000..f57d2b9 --- /dev/null +++ b/helloworld/elementary_6.c @@ -0,0 +1,46 @@ +#include + +int main() { + + int szam; + int osszeg = 0; + int szorzat = 0; + char dontes + + setbuf(stdout, NULL); + + printf("Írj egy számot: "); + scanf("%d", &szam); + + printf("A számok összegét (S) vagy szorzatát számoljam ki (P)?"); + scanf("%s", &dontes); + + if (dontes == 'S') { + + osszeg = (1 + szam)*szam/2; + setbuf(stdout, NULL); + printf("A számok összege 1-%d-ig:%d", szam, osszeg); + } + if (dontes == 'P') { + + szorzat = (1 + szam)*szam/2; + setbuf(stdout, NULL); + printf("A számok összege 1-%d-ig:%d", szam, osszeg); + int i; + for (i=1; i <= szam; i++) + { + if (i % 3 == 0 || i % 5 == 0) { + + osszeg = osszeg + i; + + } + } + + + setbuf(stdout, NULL); + printf("A hárommal vagy öttel osztható számok összege 1-%d-ig:%d", szam, osszeg); + + + return 0; +} +// kész \ No newline at end of file diff --git a/helloworld/kukutyin.c b/helloworld/kukutyin.c new file mode 100644 index 0000000..5a8df52 --- /dev/null +++ b/helloworld/kukutyin.c @@ -0,0 +1,27 @@ +#include + +int main(){ +//definiáljuk a szükséges változókat + int ellen; + int adossag; + + setbuf(stdout, NULL); + + printf("\nHány ellenség van?"); + scanf("%d", &ellen); + printf("\nHány tallér az adósság?"); + scanf("%d", &adossag); + + if ((ellen == 1 || ellen == 2 ) && adossag > 100){ + + printf("\nSKANDALUM");} + + if (ellen == 0 && adossag > 0) { + + printf("\nIMBECIL"); + } + + + +return 0; +} \ No newline at end of file From a7fb8c222f137d5c91584524888e4df62219a4bb Mon Sep 17 00:00:00 2001 From: Goodwitch68 on AcerS7 <56366861+Goodwitch68@users.noreply.github.com> Date: Wed, 16 Oct 2019 14:06:56 +0200 Subject: [PATCH 07/32] =?UTF-8?q?ez=20volt=20a=20megabyte=20megold=C3=A1sa?= =?UTF-8?q?=20ugyanerre=20a=20k=C3=A9rd=C3=A9sre?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- helloworld/elementary_7.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 helloworld/elementary_7.c diff --git a/helloworld/elementary_7.c b/helloworld/elementary_7.c new file mode 100644 index 0000000..e7a0040 --- /dev/null +++ b/helloworld/elementary_7.c @@ -0,0 +1,24 @@ +#include +#include + +int main(){ + + int szam; + int i; + int darab=0; + + for(szam=2; ; szam++) + { + darab = 0; + + for(i=1; i<=sqrt(szam); i++) + { + if(szam % i == 0){ darab++; } + if(darab>2){ break; } + } + + if( darab == 1){ printf("%d\n", szam); } + } + +return 0; +} \ No newline at end of file From 726d0855eeb1ccd22519175dd8a792bc8cbac8d3 Mon Sep 17 00:00:00 2001 From: Goodwitch68 on AcerS7 <56366861+Goodwitch68@users.noreply.github.com> Date: Wed, 16 Oct 2019 16:11:21 +0200 Subject: [PATCH 08/32] =?UTF-8?q?j=C3=B3l=20d=C3=B6nti=20el,=20hogy=20prim?= =?UTF-8?q?-e,=20de=20nem=20j=C3=B3l=20=C3=ADr=20ki?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- helloworld/elementary_7.c | 41 +++++++++++++++++++++++++-------------- 1 file changed, 26 insertions(+), 15 deletions(-) diff --git a/helloworld/elementary_7.c b/helloworld/elementary_7.c index e7a0040..c51fea9 100644 --- a/helloworld/elementary_7.c +++ b/helloworld/elementary_7.c @@ -1,24 +1,35 @@ #include #include -int main(){ +// először is korlátozzuk a számot, különben belehalunk a várakozásba, +// hiszen nagyon sok prim szám van még INT tartományban is +int main(){ int szam; + int hatar; int i; - int darab=0; - - for(szam=2; ; szam++) - { - darab = 0; - - for(i=1; i<=sqrt(szam); i++) - { - if(szam % i == 0){ darab++; } - if(darab>2){ break; } - } - - if( darab == 1){ printf("%d\n", szam); } - } + int prime; + + setbuf(stdout, NULL); + printf("Meddig terjedjen a primek kiírása? "); + scanf("%d", &hatar); + + printf("2\n"); + for(szam=3; szam <= hatar; szam = szam + 2) + {prime = 0; + for(i=2; i<=sqrt(szam+1); i++){ + if(szam % i ==0) // akkor nem prim, menj a következő osztóra + {prime = 1; + break; + } + // minden más esetben menj a következő osztóra + + } + //if (prime = 0) { + setbuf(stdout, NULL); + printf("%d %d\n", szam, prime); //kiíratom vele, hogy prim-e, hogy lássam, hol van a baj + //} + } return 0; } \ No newline at end of file From 97147f0096e31164fb7352224bb7532ff7ba8164 Mon Sep 17 00:00:00 2001 From: Goodwitch68 on AcerS7 <56366861+Goodwitch68@users.noreply.github.com> Date: Wed, 16 Oct 2019 16:16:39 +0200 Subject: [PATCH 09/32] =?UTF-8?q?itt=20nem=20=C3=ADr=20m=C3=A1r=20ki=20sem?= =?UTF-8?q?mit,=20pedig=20csak=20egy=20if-et=20tettem=20bele?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- helloworld/elementary_7.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/helloworld/elementary_7.c b/helloworld/elementary_7.c index c51fea9..dfcf96f 100644 --- a/helloworld/elementary_7.c +++ b/helloworld/elementary_7.c @@ -25,10 +25,10 @@ int main(){ // minden más esetben menj a következő osztóra } - //if (prime = 0) { + if (prime = 0) { setbuf(stdout, NULL); printf("%d %d\n", szam, prime); //kiíratom vele, hogy prim-e, hogy lássam, hol van a baj - //} + } } return 0; From 5f65aefda00a8f1600bdf1c44da6fa7d4d5993fe Mon Sep 17 00:00:00 2001 From: Goodwitch68 on AcerS7 <56366861+Goodwitch68@users.noreply.github.com> Date: Wed, 16 Oct 2019 17:03:09 +0200 Subject: [PATCH 10/32] Elementary_7 working, before adding is_prime(). --- helloworld/elementary_7.c | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/helloworld/elementary_7.c b/helloworld/elementary_7.c index dfcf96f..092b2f8 100644 --- a/helloworld/elementary_7.c +++ b/helloworld/elementary_7.c @@ -4,7 +4,13 @@ // először is korlátozzuk a számot, különben belehalunk a várakozásba, // hiszen nagyon sok prim szám van még INT tartományban is -int main(){ +/*int is_prime(int szam, int i) { + + + return prime +}*/ + +int main() { int szam; int hatar; int i; @@ -15,21 +21,20 @@ int main(){ scanf("%d", &hatar); printf("2\n"); - for(szam=3; szam <= hatar; szam = szam + 2) - {prime = 0; - for(i=2; i<=sqrt(szam+1); i++){ - if(szam % i ==0) // akkor nem prim, menj a következő osztóra - {prime = 1; + for(szam=3; szam <= hatar; szam = szam + 2) { + prime = 0; + for(i=2; i<=sqrt(szam+1); i++) { + if(szam % i ==0) { // akkor nem prim, menj a következő osztóra + prime = 1; break; - } - // minden más esetben menj a következő osztóra - + } + // minden más esetben menj a következő osztóra } - if (prime = 0) { + if (prime == 0) { setbuf(stdout, NULL); printf("%d %d\n", szam, prime); //kiíratom vele, hogy prim-e, hogy lássam, hol van a baj - } + } } -return 0; + return 0; } \ No newline at end of file From 1859aeb5be6ab96eef95e8e66c50d3139dd79aee Mon Sep 17 00:00:00 2001 From: Goodwitch68 on AcerS7 <56366861+Goodwitch68@users.noreply.github.com> Date: Thu, 17 Oct 2019 15:05:13 +0200 Subject: [PATCH 11/32] Elementary_6 working with bug in printf --- helloworld/elementary_6.c | 48 +++++++++++++++++---------------------- 1 file changed, 21 insertions(+), 27 deletions(-) diff --git a/helloworld/elementary_6.c b/helloworld/elementary_6.c index f57d2b9..3afbfff 100644 --- a/helloworld/elementary_6.c +++ b/helloworld/elementary_6.c @@ -2,45 +2,39 @@ int main() { - int szam; + int szam = 0; int osszeg = 0; - int szorzat = 0; - char dontes + int szorzat = 1; + char dontes = 'p'; setbuf(stdout, NULL); printf("Írj egy számot: "); scanf("%d", &szam); - - printf("A számok összegét (S) vagy szorzatát számoljam ki (P)?"); - scanf("%s", &dontes); - - if (dontes == 'S') { - osszeg = (1 + szam)*szam/2; + printf("A számok összegét (s) vagy szorzatát (p) számoljam ki 1-től n-ig? "); + scanf("%c", &dontes); + printf("%c", dontes); + + while (dontes != 's' && dontes !='p') { setbuf(stdout, NULL); - printf("A számok összege 1-%d-ig:%d", szam, osszeg); + printf("Kérlek nyomj s-t vagy p-t!\n"); + scanf("%c", &dontes); } - if (dontes == 'P') { - - szorzat = (1 + szam)*szam/2; - setbuf(stdout, NULL); - printf("A számok összege 1-%d-ig:%d", szam, osszeg); - int i; - for (i=1; i <= szam; i++) - { - if (i % 3 == 0 || i % 5 == 0) { - - osszeg = osszeg + i; - + if (dontes == 's') { + osszeg = (1 + szam)*szam/2; + printf("A számok összege 1-%d-ig:%d\n", szam, osszeg); + } + if (dontes == 'p') { + for (int i = 1; i <= szam; i++) { + szorzat = szorzat * i; } + printf("A számok produktuma 1-%d-ig:%d\n", szam, szorzat); } - - - setbuf(stdout, NULL); - printf("A hárommal vagy öttel osztható számok összege 1-%d-ig:%d", szam, osszeg); return 0; } -// kész \ No newline at end of file +//ebben is van még varázslat. Az előtt lefut a while ciklus, +// mielőtt be olvashatná a dontes valtozót. +//Látszólag nem csinál hülyeséget a program, mert értelmes így is, de ez hiba From f235aa4ed15a00235c5798d10f0edc9c6af0aaef Mon Sep 17 00:00:00 2001 From: Goodwitch68 on AcerS7 <56366861+Goodwitch68@users.noreply.github.com> Date: Thu, 17 Oct 2019 15:10:24 +0200 Subject: [PATCH 12/32] Elementary_8 working --- helloworld/elementary_8.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 helloworld/elementary_8.c diff --git a/helloworld/elementary_8.c b/helloworld/elementary_8.c new file mode 100644 index 0000000..45042a5 --- /dev/null +++ b/helloworld/elementary_8.c @@ -0,0 +1,26 @@ +#include + + +// ez tképpen a 7-es feladat, csak benéztem a számot + +int main(){ + + int i; + int j; + + //setbuf(stdout, NULL); + printf("A szorzótábla\n "); + + for(i=1; i <= 12; i++){ + setbuf(stdout, NULL); + printf("\nAz %d-s szorzótábla:\n", i); + + for(j=1; j<= 12; j++){ + printf("%d * %d = %d\n", j, i, i*j); + } + } + +return 0; +} + +//kész \ No newline at end of file From febeedfc61f3cc61fcf5d0963e863981f39543a9 Mon Sep 17 00:00:00 2001 From: Goodwitch68 on AcerS7 <56366861+Goodwitch68@users.noreply.github.com> Date: Thu, 17 Oct 2019 17:14:46 +0200 Subject: [PATCH 13/32] Elementary_6 properly working ver --- helloworld/elementary_6.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/helloworld/elementary_6.c b/helloworld/elementary_6.c index 3afbfff..4fd8798 100644 --- a/helloworld/elementary_6.c +++ b/helloworld/elementary_6.c @@ -13,11 +13,10 @@ int main() { scanf("%d", &szam); printf("A számok összegét (s) vagy szorzatát (p) számoljam ki 1-től n-ig? "); - scanf("%c", &dontes); + scanf(" %c", &dontes); printf("%c", dontes); while (dontes != 's' && dontes !='p') { - setbuf(stdout, NULL); printf("Kérlek nyomj s-t vagy p-t!\n"); scanf("%c", &dontes); } From dce717a3c9702939cc100f91a2840256c3e22af9 Mon Sep 17 00:00:00 2001 From: Goodwitch68 on AcerS7 <56366861+Goodwitch68@users.noreply.github.com> Date: Sat, 19 Oct 2019 09:03:35 +0200 Subject: [PATCH 14/32] Elementary_9 working, without eliminating of consecutiv repeatition --- helloworld/elementary_9.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 helloworld/elementary_9.c diff --git a/helloworld/elementary_9.c b/helloworld/elementary_9.c new file mode 100644 index 0000000..a583197 --- /dev/null +++ b/helloworld/elementary_9.c @@ -0,0 +1,34 @@ +#include +#include + +int main(int argc, char *argv[]) +{ + int a; + srand(time(NULL)); + a = rand() % 100 + 1; + + int number; + int trials = 0; + + setbuf(stdout, NULL); + //printf(" %d", a); + + printf("\nGondoltam egy számra 1 és 100 között, találd ki melyikre! \n"); + scanf(" %d", &number); + trials++; + + while (number != a){ + trials++; + if (number < a){ + printf("Nem talált, a szám kisebb, mint a Te tipped. Próbáld újra! \n"); + scanf(" %d", &number); + } + else { + printf("Nem talált, a szám nagyobb, mint a Te tipped. Próbáld újra! \n"); + scanf(" %d", &number); + } + } + printf("Szuper! Eltaláltad! %d-t találgattál.\n", trials); + return 0; +} +//Az ismétlések eliminálása még nincs benne \ No newline at end of file From 8b359266ba5af9f911ef0228d6783f674f7b613c Mon Sep 17 00:00:00 2001 From: Goodwitch68 on AcerS7 <56366861+Goodwitch68@users.noreply.github.com> Date: Sat, 19 Oct 2019 11:05:56 +0200 Subject: [PATCH 15/32] elementary_9 proper working --- helloworld/elementary_9.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/helloworld/elementary_9.c b/helloworld/elementary_9.c index a583197..fd9bf6a 100644 --- a/helloworld/elementary_9.c +++ b/helloworld/elementary_9.c @@ -8,6 +8,7 @@ int main(int argc, char *argv[]) a = rand() % 100 + 1; int number; + int old_number = 0; int trials = 0; setbuf(stdout, NULL); @@ -27,8 +28,12 @@ int main(int argc, char *argv[]) printf("Nem talált, a szám nagyobb, mint a Te tipped. Próbáld újra! \n"); scanf(" %d", &number); } + if (old_number == number) { + trials--; + printf("ezt a számot épp most írtad, figyelj jobban!"); + } + old_number = number; } printf("Szuper! Eltaláltad! %d-t találgattál.\n", trials); return 0; } -//Az ismétlések eliminálása még nincs benne \ No newline at end of file From c5a2e5f31b3486da82b6370b0aa8f75e87f37840 Mon Sep 17 00:00:00 2001 From: Goodwitch68 on AcerS7 <56366861+Goodwitch68@users.noreply.github.com> Date: Sat, 19 Oct 2019 11:33:28 +0200 Subject: [PATCH 16/32] elementary_9 better --- helloworld/elementary_9.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/helloworld/elementary_9.c b/helloworld/elementary_9.c index fd9bf6a..f479b68 100644 --- a/helloworld/elementary_9.c +++ b/helloworld/elementary_9.c @@ -12,28 +12,31 @@ int main(int argc, char *argv[]) int trials = 0; setbuf(stdout, NULL); - //printf(" %d", a); - + printf(" %d", a); printf("\nGondoltam egy számra 1 és 100 között, találd ki melyikre! \n"); scanf(" %d", &number); trials++; while (number != a){ trials++; + printf("régi szám:%d, új szám:%d", old_number, number); + if (old_number == number) { + trials--; + printf("ezt a számot épp most írtad, figyelj jobban!\n"); + } if (number < a){ printf("Nem talált, a szám kisebb, mint a Te tipped. Próbáld újra! \n"); + old_number = number; scanf(" %d", &number); - } + } else { printf("Nem talált, a szám nagyobb, mint a Te tipped. Próbáld újra! \n"); + old_number = number; scanf(" %d", &number); - } - if (old_number == number) { - trials--; - printf("ezt a számot épp most írtad, figyelj jobban!"); - } - old_number = number; + } + } printf("Szuper! Eltaláltad! %d-t találgattál.\n", trials); return 0; } +//most jó \ No newline at end of file From 5d747d0e5671487114ab0ce55eab485e877f31b1 Mon Sep 17 00:00:00 2001 From: Goodwitch68 on AcerS7 <56366861+Goodwitch68@users.noreply.github.com> Date: Sat, 19 Oct 2019 12:43:30 +0200 Subject: [PATCH 17/32] elementary_10 proper working --- helloworld/elementary_10.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 helloworld/elementary_10.c diff --git a/helloworld/elementary_10.c b/helloworld/elementary_10.c new file mode 100644 index 0000000..ffe9fb1 --- /dev/null +++ b/helloworld/elementary_10.c @@ -0,0 +1,34 @@ +#include +#include +int main() +{ + time_t s, val = 1; + struct tm* current_time; + + s = time(NULL); + + current_time = localtime(&s); + + printf("Current year = %d\n",(current_time->tm_year + 1900)); + + + int current_year = current_time->tm_year + 1900; + int next_leap_year = 4 - current_year % 4; + int leap_year = current_year + next_leap_year; + + for (int i = 0; i< 20; i++){ + if (leap_year % 100 == 0){ + i--; + } + else { + printf("%d, ", leap_year); + } + leap_year = leap_year + 4; + } + + + + return 0; +} + +//2920-ig használható, később tévesen kihagyja a 3000-et \ No newline at end of file From b2c70dfd722d0f69bdada24bc712e5aa6499f782 Mon Sep 17 00:00:00 2001 From: Goodwitch68 on AcerS7 <56366861+Goodwitch68@users.noreply.github.com> Date: Sat, 19 Oct 2019 12:44:42 +0200 Subject: [PATCH 18/32] Interesting problem to discuss --- helloworld/elementary_10_fura.c | 39 +++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 helloworld/elementary_10_fura.c diff --git a/helloworld/elementary_10_fura.c b/helloworld/elementary_10_fura.c new file mode 100644 index 0000000..54300e6 --- /dev/null +++ b/helloworld/elementary_10_fura.c @@ -0,0 +1,39 @@ +#include +#include +int main() +{ + time_t s, val = 1; + struct tm* current_time; + + s = time(NULL); + + current_time = localtime(&s); + + printf("Day of the month = %d\n",current_time->tm_mday); + printf("Day in this year = %d\n",current_time->tm_yday); + printf("Day in this week = %d\n",current_time->tm_wday); + printf("Month of this year = %d\n",(current_time->tm_mon + 1)); + printf("Current year = %d\n",(current_time->tm_year + 1900)); + printf("hour:min:sec = %02d:%02d:%02d\n", + current_time->tm_hour, + current_time->tm_min, + current_time->tm_sec); + +/* int current_year = current_time->tm_year + 1900; + int next_leap_year = 4 - current_year % 4; + int leap_year = current_year + next_leap_year; + + for (int i = 0; i< 20; i++){ + if (leap_year % 100 == 0){ + i--; + } + else { + printf("%d, ", leap_year); + } + leap_year = leap_year + 4; + }*/ + + + return 0; +} + From 98cd6a55989b9e73ad6546543cc8842129046522 Mon Sep 17 00:00:00 2001 From: Goodwitch68 on AcerS7 <56366861+Goodwitch68@users.noreply.github.com> Date: Sat, 19 Oct 2019 13:43:29 +0200 Subject: [PATCH 19/32] Elementary-11 proper working --- helloworld/elementary_11.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 helloworld/elementary_11.c diff --git a/helloworld/elementary_11.c b/helloworld/elementary_11.c new file mode 100644 index 0000000..53522b8 --- /dev/null +++ b/helloworld/elementary_11.c @@ -0,0 +1,25 @@ +//Write a program that computes the sum of an alternating series where each element +// of the series is an expression of the form ((-1)^{k+1})/(2 * k-1) +//for each value of k from 1 to a million, multiplied by 4. +//Or, in more mathematical notation +// 4\cdot \sum_{k=1}^{10^6} \frac{(-1)^{k+1}}{2k-1} = 4\cdot(1-1/3+1/5-1/7+1/9-1/11\ldots) + +#include +#include + + + +int main(){ + + double sum = 0; + for (double k = 1; k<= 1000000; k++){ + sum = sum + (pow (-1, k)/(2*k-1)); + printf("\nSum*4 is 1-%f-ig: %f", k, sum*4); + + } + return 0; +} + +//double pow(double x, double y); +//Here, the value of the double variable x is raised to the power of y. +//The pow() function returns the result in the double data type. \ No newline at end of file From b4911af2092c26a199f49a1a8dbcc646363a61cb Mon Sep 17 00:00:00 2001 From: Goodwitch68 on AcerS7 <56366861+Goodwitch68@users.noreply.github.com> Date: Tue, 22 Oct 2019 15:00:10 +0200 Subject: [PATCH 20/32] Elementary_6 done, committed earlier --- helloworld/elementary_6.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/helloworld/elementary_6.c b/helloworld/elementary_6.c index 4fd8798..74c99f4 100644 --- a/helloworld/elementary_6.c +++ b/helloworld/elementary_6.c @@ -34,6 +34,4 @@ int main() { return 0; } -//ebben is van még varázslat. Az előtt lefut a while ciklus, -// mielőtt be olvashatná a dontes valtozót. -//Látszólag nem csinál hülyeséget a program, mert értelmes így is, de ez hiba +//most jól fut From f3350682972c9dd140c78b6fc510d97a3f23687c Mon Sep 17 00:00:00 2001 From: Goodwitch68 on AcerS7 <56366861+Goodwitch68@users.noreply.github.com> Date: Tue, 22 Oct 2019 15:01:20 +0200 Subject: [PATCH 21/32] Elementary_7 done, committed earlier --- helloworld/elementary_7.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/helloworld/elementary_7.c b/helloworld/elementary_7.c index 092b2f8..2787fd7 100644 --- a/helloworld/elementary_7.c +++ b/helloworld/elementary_7.c @@ -32,7 +32,7 @@ int main() { } if (prime == 0) { setbuf(stdout, NULL); - printf("%d %d\n", szam, prime); //kiíratom vele, hogy prim-e, hogy lássam, hol van a baj + printf("%d\n", szam); //kiíratom vele, hogy prim-e, hogy lássam, hol van a baj } } From c73e8764637ee8ad96439c172e602d3e8368c35d Mon Sep 17 00:00:00 2001 From: Goodwitch68 on AcerS7 <56366861+Goodwitch68@users.noreply.github.com> Date: Tue, 22 Oct 2019 15:02:00 +0200 Subject: [PATCH 22/32] Elementary_8 done, committed earlier --- helloworld/elementary_8.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/helloworld/elementary_8.c b/helloworld/elementary_8.c index 45042a5..520c628 100644 --- a/helloworld/elementary_8.c +++ b/helloworld/elementary_8.c @@ -20,7 +20,7 @@ int main(){ } } -return 0; + return 0; } //kész \ No newline at end of file From d2d9c4b61aec97573565b87c5d8fe6a073b466bb Mon Sep 17 00:00:00 2001 From: Goodwitch68 on AcerS7 <56366861+Goodwitch68@users.noreply.github.com> Date: Fri, 25 Oct 2019 11:48:27 +0200 Subject: [PATCH 23/32] Elementary_2_3 Bob == Bob return 0, why? --- helloworld/elementary_2_3.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/helloworld/elementary_2_3.c b/helloworld/elementary_2_3.c index 1aad190..5692194 100644 --- a/helloworld/elementary_2_3.c +++ b/helloworld/elementary_2_3.c @@ -2,19 +2,21 @@ int main() { - char name[100] ;/* define name */ + char name [100]; /* define name */ setbuf(stdout, NULL); printf("Hogy hívnak? "); scanf("%s", &name); - if (name[0] == 'A' || name[0] == 'B') { + if ( name == "Alice" || name == "Bob") { setbuf(stdout, NULL); printf("Üdvözöllek, %s!", name); } + printf("%s!", name); + printf ("%d\n", name == "Bob"); return 0; } From b6cb2f05d574bf76166f0bfcbd2556eaa26e3a28 Mon Sep 17 00:00:00 2001 From: Goodwitch68 on AcerS7 <56366861+Goodwitch68@users.noreply.github.com> Date: Fri, 25 Oct 2019 11:50:41 +0200 Subject: [PATCH 24/32] elementary_2_3.c intended proper way --- helloworld/elementary_2_3.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/helloworld/elementary_2_3.c b/helloworld/elementary_2_3.c index 5692194..8a0416b 100644 --- a/helloworld/elementary_2_3.c +++ b/helloworld/elementary_2_3.c @@ -2,11 +2,11 @@ int main() { - char name [100]; /* define name */ - - setbuf(stdout, NULL); + char name [100]; /* define name */ + + setbuf(stdout, NULL); - printf("Hogy hívnak? "); + printf("Hogy hívnak? "); scanf("%s", &name); if ( name == "Alice" || name == "Bob") { @@ -14,7 +14,7 @@ int main() { setbuf(stdout, NULL); printf("Üdvözöllek, %s!", name); } - + printf("%s!", name); printf ("%d\n", name == "Bob"); From 4c30325010d5b288336d2ebbf53a4b27df10ab68 Mon Sep 17 00:00:00 2001 From: Goodwitch68 on AcerS7 <56366861+Goodwitch68@users.noreply.github.com> Date: Fri, 25 Oct 2019 11:53:34 +0200 Subject: [PATCH 25/32] elementary_4.c intended proper way --- helloworld/elementary_4.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/helloworld/elementary_4.c b/helloworld/elementary_4.c index e80e135..4b11a0a 100644 --- a/helloworld/elementary_4.c +++ b/helloworld/elementary_4.c @@ -2,20 +2,17 @@ int main() { - int szam; + int szam; int osszeg; - - setbuf(stdout, NULL); - - printf("Írj egy számot: "); - scanf("%d", &szam); + setbuf(stdout, NULL); + printf("Írj egy számot: "); + scanf("%d", &szam); + osszeg = (1+szam)*szam/2; // persze lehetett volna nagyon idétlen ciklussal is megoldani, de ez elegánsabb megoldásnak tűnt :-) - //a - // setbuf(stdout, NULL); printf("A számok összege 1-%d-ig:%d", szam, osszeg); - + return 0; } From f222325d45e5c4f8b51d5b2341599edd5d8c3940 Mon Sep 17 00:00:00 2001 From: Goodwitch68 on AcerS7 <56366861+Goodwitch68@users.noreply.github.com> Date: Fri, 25 Oct 2019 11:58:55 +0200 Subject: [PATCH 26/32] elementary_4_5.c intended proper way --- helloworld/elementary_4_5.c | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/helloworld/elementary_4_5.c b/helloworld/elementary_4_5.c index ae0e677..f85ed3e 100644 --- a/helloworld/elementary_4_5.c +++ b/helloworld/elementary_4_5.c @@ -2,31 +2,23 @@ int main() { - int szam; + int szam; int osszeg = 0; - - setbuf(stdout, NULL); - - printf("Írj egy számot: "); + + setbuf(stdout, NULL); + printf("Írj egy számot: "); scanf("%d", &szam); // és akkor most legyen itt ciklussal, mert erre nincs matematikai képlet, bár gondolkozom rajta :-) int i; - for (i=1; i <= szam; i++) - { + for (i = 1; i <= szam; i++) { if (i % 3 == 0 || i % 5 == 0) { - osszeg = osszeg + i; - } } - - setbuf(stdout, NULL); printf("A hárommal vagy öttel osztható számok összege 1-%d-ig:%d", szam, osszeg); - - return 0; } // kész \ No newline at end of file From 03ef10d6e978d651c7595529ada5ff87e7018e6e Mon Sep 17 00:00:00 2001 From: Goodwitch68 on AcerS7 <56366861+Goodwitch68@users.noreply.github.com> Date: Fri, 25 Oct 2019 12:07:43 +0200 Subject: [PATCH 27/32] elementary_6 intended proper way --- helloworld/elementary_6.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/helloworld/elementary_6.c b/helloworld/elementary_6.c index 74c99f4..554b3c1 100644 --- a/helloworld/elementary_6.c +++ b/helloworld/elementary_6.c @@ -2,17 +2,17 @@ int main() { - int szam = 0; + int szam = 0; int osszeg = 0; int szorzat = 1; char dontes = 'p'; - - setbuf(stdout, NULL); + + setbuf(stdout, NULL); - printf("Írj egy számot: "); + printf("Írj egy számot: "); scanf("%d", &szam); - - printf("A számok összegét (s) vagy szorzatát (p) számoljam ki 1-től n-ig? "); + + printf("A számok összegét (s) vagy szorzatát (p) számoljam ki 1-től n-ig? "); scanf(" %c", &dontes); printf("%c", dontes); @@ -30,8 +30,6 @@ int main() { } printf("A számok produktuma 1-%d-ig:%d\n", szam, szorzat); } - - return 0; } //most jól fut From d0cfd51489e2fc073e1570084c6e7b59f4cce0e6 Mon Sep 17 00:00:00 2001 From: Goodwitch68 on AcerS7 <56366861+Goodwitch68@users.noreply.github.com> Date: Fri, 25 Oct 2019 12:12:40 +0200 Subject: [PATCH 28/32] elementary_7 intended proper way --- helloworld/elementary_7.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/helloworld/elementary_7.c b/helloworld/elementary_7.c index 2787fd7..c6d003d 100644 --- a/helloworld/elementary_7.c +++ b/helloworld/elementary_7.c @@ -11,19 +11,19 @@ }*/ int main() { - int szam; + int szam; int hatar; - int i; + int i; int prime; setbuf(stdout, NULL); printf("Meddig terjedjen a primek kiírása? "); scanf("%d", &hatar); - + printf("2\n"); - for(szam=3; szam <= hatar; szam = szam + 2) { - prime = 0; - for(i=2; i<=sqrt(szam+1); i++) { + for(szam = 3; szam <= hatar; szam = szam + 2) { + prime=0; + for(i = 2; i <= sqrt(szam+1); i++) { if(szam % i ==0) { // akkor nem prim, menj a következő osztóra prime = 1; break; From e56181553dc3359b0f31fe8cfedfac83ae917176 Mon Sep 17 00:00:00 2001 From: Goodwitch68 on AcerS7 <56366861+Goodwitch68@users.noreply.github.com> Date: Fri, 25 Oct 2019 12:15:24 +0200 Subject: [PATCH 29/32] elementary_8 intended proper way --- helloworld/elementary_8.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/helloworld/elementary_8.c b/helloworld/elementary_8.c index 520c628..03ddb33 100644 --- a/helloworld/elementary_8.c +++ b/helloworld/elementary_8.c @@ -4,19 +4,17 @@ // ez tképpen a 7-es feladat, csak benéztem a számot int main(){ - - int i; + + int i; int j; - //setbuf(stdout, NULL); printf("A szorzótábla\n "); - - for(i=1; i <= 12; i++){ + + for(i = 1; i <= 12; i++){ setbuf(stdout, NULL); printf("\nAz %d-s szorzótábla:\n", i); - - for(j=1; j<= 12; j++){ - printf("%d * %d = %d\n", j, i, i*j); + for(j = 1; j <= 12; j++){ + printf("%d * %d = %d\n", j, i, i*j); } } From 9a1d9b1ed87fc28be66299b111d6bdc2b51ff030 Mon Sep 17 00:00:00 2001 From: Goodwitch68 on AcerS7 <56366861+Goodwitch68@users.noreply.github.com> Date: Fri, 25 Oct 2019 12:16:44 +0200 Subject: [PATCH 30/32] elementary_9 intended proper way --- helloworld/elementary_9.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/helloworld/elementary_9.c b/helloworld/elementary_9.c index f479b68..2f50ec0 100644 --- a/helloworld/elementary_9.c +++ b/helloworld/elementary_9.c @@ -3,14 +3,14 @@ int main(int argc, char *argv[]) { - int a; - srand(time(NULL)); - a = rand() % 100 + 1; - + int a; + srand(time(NULL)); + a = rand() % 100 + 1; + int number; int old_number = 0; int trials = 0; - + setbuf(stdout, NULL); printf(" %d", a); printf("\nGondoltam egy számra 1 és 100 között, találd ki melyikre! \n"); From 95a5c877cd6ab110d2442e76e3ee08e30996dee5 Mon Sep 17 00:00:00 2001 From: Goodwitch68 on AcerS7 <56366861+Goodwitch68@users.noreply.github.com> Date: Fri, 25 Oct 2019 12:28:58 +0200 Subject: [PATCH 31/32] elementary_10 intended proper way --- helloworld/elementary_10.c | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/helloworld/elementary_10.c b/helloworld/elementary_10.c index ffe9fb1..ce443d1 100644 --- a/helloworld/elementary_10.c +++ b/helloworld/elementary_10.c @@ -1,22 +1,19 @@ #include #include -int main() -{ - time_t s, val = 1; - struct tm* current_time; - - s = time(NULL); - - current_time = localtime(&s); - - printf("Current year = %d\n",(current_time->tm_year + 1900)); - - +int main() { + + time_t s, val = 1; + struct tm* current_time; + + s = time(NULL); + + current_time = localtime(&s); + printf("Current year = %d\n",(current_time->tm_year + 1900)); int current_year = current_time->tm_year + 1900; int next_leap_year = 4 - current_year % 4; int leap_year = current_year + next_leap_year; - for (int i = 0; i< 20; i++){ + for (int i = 0; i < 20; i++){ if (leap_year % 100 == 0){ i--; } @@ -25,9 +22,6 @@ int main() } leap_year = leap_year + 4; } - - - return 0; } From 14041598be4ec6bad9ddb352f940735df99627b7 Mon Sep 17 00:00:00 2001 From: Goodwitch68 on AcerS7 <56366861+Goodwitch68@users.noreply.github.com> Date: Fri, 25 Oct 2019 12:30:20 +0200 Subject: [PATCH 32/32] elementary_11 intended proper way --- helloworld/elementary_11.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/helloworld/elementary_11.c b/helloworld/elementary_11.c index 53522b8..1e018e6 100644 --- a/helloworld/elementary_11.c +++ b/helloworld/elementary_11.c @@ -7,17 +7,14 @@ #include #include - - int main(){ double sum = 0; for (double k = 1; k<= 1000000; k++){ sum = sum + (pow (-1, k)/(2*k-1)); printf("\nSum*4 is 1-%f-ig: %f", k, sum*4); - } - return 0; + return 0; } //double pow(double x, double y);