From 10eac621ecd2aa0799a2b5b115219b39861c3a6e Mon Sep 17 00:00:00 2001 From: Matus Tokarcik Date: Thu, 28 Mar 2024 21:45:33 +0100 Subject: [PATCH] a1 --- a1/program.c | 78 +++++++++++++++++++++++---------------- a1/program.exe | Bin 66598 -> 66598 bytes a1/program.exe.stackdump | 21 +++++------ 3 files changed, 56 insertions(+), 43 deletions(-) diff --git a/a1/program.c b/a1/program.c index 02e6e4d..004c252 100644 --- a/a1/program.c +++ b/a1/program.c @@ -7,46 +7,62 @@ int main(){ char pole[100]; - char* a = fgets(pole, 100, stdin); double cislo1; double cislo2; double vysledok; char znamienko; char* token; + char vysledky[50][50]; // pole pre ukladanie vysledkov + int pocet = 0; - token = strtok(pole, " "); //rozdelenie retazca podla medzier - cislo1 = atof(token); // premena stringu na desatinne cislo a priradenie cislu1 - token = strtok(NULL, " "); //pokracovanie v rozdelovani retazca - znamienko = token[0]; // vrati ukazatel na nasledujuci token, cize znamienko - token = strtok(NULL, " =\n"); - cislo2 = atof(token); - token = strtok(NULL, " =\n"); - vysledok = atof(token); + while (1) { + char* a = fgets(pole, 100, stdin); - double realny; + if (pole[0] == '\n') { //ci je riadok prazdny, ci sa stlacil enter + break; + } - switch (znamienko){ - case '+': - realny = cislo1 + cislo2; - break; - case '-': - realny = cislo1 - cislo2; - break; - case '*': - realny = cislo1 * cislo2; - break; - case '/': - realny =cislo1 / cislo2; - break; - default: - printf("CHYBA\n"); - return 1; + token = strtok(pole, " "); //rozdelenie retazca podla medzier + cislo1 = atof(token); // premena stringu na desatinne cislo a priradenie cislu1 + token = strtok(NULL, " "); //pokracovanie v rozdelovani retazca + znamienko = token[0]; //vrati ukazatel na nasledujuci token, cize znamienko + token = strtok(NULL, " =\n"); + cislo2 = atof(token); + token = strtok(NULL, " =\n"); + vysledok = atof(token); + + double realny; + + switch (znamienko){ + case '+': + realny = cislo1 + cislo2; + break; + case '-': + realny = cislo1 - cislo2; + break; + case '*': + realny = cislo1 * cislo2; + break; + case '/': + realny = cislo1 / cislo2; + break; + default: + printf("CHYBA\n"); + return 1; + } + + if (realny == vysledok){ + strcpy(vysledky[pocet], "OK"); //kopiruje vysledok do pola vysledky + } + else{ + strcpy(vysledky[pocet], "ZLE"); + } + pocet++; } - if (realny == vysledok){ - printf ("OK\n"); - } - else{ - printf ("ZLE\n"); + + //vypis vysledkov + for (int i = 0; i < pocet; i++) { + printf("%s\n", vysledky[i]); } return 0; diff --git a/a1/program.exe b/a1/program.exe index ade65e91f89878e7aa58683eb49a4ec122b4f4c1..c0b92d4373be59f3f508e2755c30861928982fcf 100644 GIT binary patch delta 3631 zcmai14^&gv8Nc_2K*GN~BoU%OV+@fx#ZYPMsztP-uNGZoSn+?l_Mr2CrWT#2hhuOd z9f73-?#^aCb&a+2Xb&pxSx0Nz6OmKasu;0V(OQGWH6V5o6)Bx#-+eEdgr1$fbME`T z-}nE1_j?zzuO@0=O;mjislCupyO_Aj8ZI9rElS#m7n1-MuH(s3Hn$9+f*emyXU^yT zqhWkY82@pI=k0A-y$sifJ%uj$0Tn_yoxCf7LkRU=AqbV0W~&~n287VbFk8kh<#+VE zV-ezAO*TUn82C?tL%SmlWbE-b0p#n<3f|?gDiM0#>HX*xkn_$H{u4~)bRaNQ9TT;) zVpY}AOez`kE=~GllI;hQ?GS|E>l`A12%A7!%B!|}AWXokBP|R-oiJR&e zs&V{FGCdh?TKp4JR%2pV2A|~R3irwgdD+4WyM#l9T>>}Nr(#a~(6owm@Um6fho)9M z4lmng`_SZypWBCiwq^Z*igN_OctBO+V7UfVNe&L0b8}rtvno=vD5P0#i&RYysn$el zw9uuFbg8dqD6|C@>h;5mxv-3-s%!@<`}Km+k}cDD*CKbFc)tA0Uf${DPxuIry}Zk& zcCel^9(#EFkJ5JZix)o2C+KGO|MVH<(vDUX79hJA9rw097#XQ=cfE_c?7=}ls z7Q@&=soBYGgIesOGp-ZKOfhWb@fNYl9c^rES4;CelDVrq{5u%QY#fDaN8!=>_sh{U zVIR^+=0~F(A~A38&&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