From 6266b9d3fadb8187fd54af5730bb66445b11427d Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 3 Oct 2020 13:03:18 +0200 Subject: [PATCH] aa --- cv1/program.c | 42 ++++++++++++----------- cv1/program.exe | Bin 45485 -> 46150 bytes program.c | 86 +++++++++++++++++++++++++++++++++++++----------- 3 files changed, 88 insertions(+), 40 deletions(-) diff --git a/cv1/program.c b/cv1/program.c index 048f6b0..736079a 100644 --- a/cv1/program.c +++ b/cv1/program.c @@ -6,6 +6,7 @@ #define LINESIZE 100 #define LINE_SIZE 100 + struct pizza { float prize; char name[LINESIZE]; @@ -18,11 +19,12 @@ struct pizza nulova; int main(){ int POCET_JEDAL=0; + struct pizza jedalny_listok[POCET_JEDAL]; // Nastavíme všetky bajty pamäte na nulu // Alebo staticky priradime nejake hodnoty memset(&tuniakova, 0,sizeof(struct pizza)); // Pozor, táto inicializácia funguje iba na novších prekladačoch - struct pizza jedalny_listok[POCET_JEDAL]; + //struct pizza jedalny_listok[POCET_JEDAL]; // Na začiatku celé pole vynulujeme, všetky pizze sú nulové memset(jedalny_listok, 0,sizeof(struct pizza)*POCET_JEDAL); struct pizza *prva = jedalny_listok; @@ -37,26 +39,24 @@ int main(){ char* r = fgets(line,LINE_SIZE,stdin); // Overím si či bolo načítanie úspešné. return 0; - } - struct pizza item; int counter = 1; - while(read_pizza(stdin,&item)){ + /* while(read_pizza(stdin,&item)){ counter += 1; - printf("%s",item->name); - printf("%.2f",item->prize); - } + printf("%s",item.name); + printf("%.2f",item.prize); + }*/ } int search_string(const char* heap, const char* needle){ char pole[5]="abcd"; for (int i = 0; i < 5; i++){ printf("%c",pole[i+1]); } - } - - int read_pizza(struct pizza* item){ - float value = strtof(line,struct pizza); + }/* + int read_pizza(stdin,&item){ + char line[LINE_SIZE]; + float value = strtof(line,NULL); // Ak je návratová hodnota nula, premena reťazca sa nepodarila. if (value == 0.0F){ return 0; @@ -65,25 +65,27 @@ int main(){ strcpy(item->name, line); return 1; } - +*/ char hacker_script(char c){ char numbers[] = "0123456789"; char letters[] = "oizeasbtbq"; for (int i = 0; i < 10; i++){ - if (tolower(c) == numbers[i]){ + tolower(c); + if (c == numbers[i]){ return letters[i]; } } + return c; } //////////////////////// -// //////// -// /////// ////// -// //////// ////// -// //////// ////// -// ////// ////// -// //// ///////// -// //////////// +// ///////// +// /////// /////// +// //////// /////// +// //////// /////// +// ////// //////// +// //// ////////// +// ///////////// // /// /////////// // //// ////////// // ///// ///////// diff --git a/cv1/program.exe b/cv1/program.exe index 8bb447710464391414123c86f4d43723951be22d..151cbb1478eba02b94a56ea990f16cfd3f2707f8 100644 GIT binary patch delta 7670 zcmchbdt6jUmdC4ZcOxo7gP@2g4c+1!Fp)pDjM8 zs_(Z>ojT`K-MaU3>~p2Xr8u_6xgJ|%W>t*c;Ec7i9=tbKbnF4f*vz{9nMxk7`*gSx z9YU|G#*vZ7YO?AWbJZmdBx6;mq8>w4d^IniANeD_qC+sq0SToU%1C-q=}QhJhR>## zl%aes{TcP+bW0gZCRH?zQAP80G*LB_cBmq0y{bRoK+mgQR*F+8Tb(s&<~mLjG#P_OgV^46fAyDp zZg&?8YM~LCLUkHr{&t~qRqgtq2V?sV78sdbZE%HXp^yl*eYy=swy9~=R97bSs$&ib z1+D8=9}K$E;hNqPdP7nuCM0p%ccU4z#~WN#LUGWEIw->D17bvVo>o{r1PzZt(NUe3 zCRl^a3Iy9QnyNxf{hmgb?acUQhwW-S!WPlHWA@VDLK3WdVcqotf~q}{EW)j|Bs2Gr zHc&rUjq4^{I|5~v{qM6MwO!T16kCYllZE-K>P=0SRX${IcJ=kb0~H8cB&;tqMNnQI zYHty6c&LxwBU_KEv=>Hs44rRwIBKUE)X0nbsZPu`XZE9o&t46M->$JpuD#vf+G@JO z7|jV?-0#2$#)hA%%{PSEnpCG<%IS8+Zn{JhLSxn6qKn=S9l$@NZ$eY8%iM0a$Vwyd zK3`fxg&T`S;G6v2$IxvzU3gQZ!`@k2((%~51?FGX7Iikm72DNet)}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F-e1s1UV*= zr$Jsz!@Jt|)XE2%A&F*z?3V^x3-XGjv4TvJNE?Va@YBgX>Hh**E@{q!bZgj5=TdP+ zb`@xzS7bDnuUxrw8LO0rSK*-;r)eEA7MVyYznQ6TLSNfyb&;hWZY5cyutF}p=R*A;?Dw@_$WCD%YoCQ_{j0){27p|5}5)r0)Bj&xgd-gdfbI2AhRXU zFPnu(%3c#lyCixS#4ZiCALOhQ^shmtdNsx+(W-J2Q%jBl``}S24L<W8gGqrute8FwQ{ zl;oh9e!o*^-V1KWP`)`I0Ev~zQ4n$X7UdZb@q^sg>vxhytkMOmm$Q>n#_Z5skOKWd z4HQh~T`>a#@wW9%**L$fvU1sc{1*Myt{C$mw28yLV2w*wEm~X7W=P>ALvu}XJ|5(* zq?sc8AfdjUJQrkv)ax~n%M#f%3#bx3ebMd)=>!o^WY-O92a%u8pMzvbjxK^6lQQzh zKsvBH-h2xUGrdydsznt`%PQGjuN1$WoY_c_qR|9B`O@tN(&qJpxiKAxID8S8g7o*U z8_~AZ4AdocdktiPG}s2GBW({yyFs+*?pqayotmDz{}T}L`QRJ=3y??BSeJsZAzL95 ziF76NIz*liW_8ekkTi6S@mcqvWU$e(S};hi|h*fJ~4yqd=0O@!iVYV7!=4 zO0MTYlpu+ggH%e6TIlt?I`aW=;2!av0uhHV;){YHF5mO!I>>GpbO-!*kg3uf9)fs& z4Y`sMfFG{n@c9{P2J$_)L}MDrZtp~m3oFV^tFR0u*Av~2d{g`>h{4-S_^IrrsRdDc z!w?(1vfR9sUGpwd(QPY4JG_p>lXS_lHRZw5@E<^f_1EJTd #include +#include +#include #define LINESIZE 100 #define LINE_SIZE 100 @@ -8,39 +10,83 @@ struct pizza { float prize; char name[LINESIZE]; }; +struct pizza nulova; + struct pizza tuniakova = { + .name="Tuniakova", + .prize=2.3 + }; int main(){ int POCET_JEDAL=0; + // Nastavíme všetky bajty pamäte na nulu + // Alebo staticky priradime nejake hodnoty + memset(&tuniakova, 0,sizeof(struct pizza)); + // Pozor, táto inicializácia funguje iba na novších prekladačoch struct pizza jedalny_listok[POCET_JEDAL]; // Na začiatku celé pole vynulujeme, všetky pizze sú nulové memset(jedalny_listok, 0,sizeof(struct pizza)*POCET_JEDAL); struct pizza *prva = jedalny_listok; struct pizza *druha = jedalny_listok + 1; struct pizza *tretia = &jedalny_listok[2]; - int read_pizza(struct pizza* item); char line[LINE_SIZE]; while (1){ - // Inicializujem pamäť - memset(line,0,LINE_SIZE); - // Do poľa načítam max. LINE_SIZE znakov zo štandardnéhgo vstupu. - char* r = fgets(line,LINE_SIZE,stdin); - // Overím si či bolo načítanie úspešné. - if(r != NULL && line[1] != 0){ - // Načítanie je úspešné ak fgets vráti nenulovú hodnotu a načítaný reťazec je dlhši ako jeden znak - printf("%s",line); - } + // Inicializujem pamäť + memset(line,0,LINE_SIZE); + // Do poľa načítam max. LINE_SIZE znakov zo štandardnéhgo vstupu. + char* r = fgets(line,LINE_SIZE,stdin); + // Overím si či bolo načítanie úspešné. + return 0; + + } + + struct pizza item; + int counter = 1; + while(read_pizza(stdin,&item)){ + counter += 1; + printf("%s",item->name); + printf("%.2f",item->prize); } - //printf("%s má cenu %.2f\n",item->name,item->prize); - char hacker_script(char c); - return 0; } -char hacker_script(char c){ - char numbers[] = "0123456789"; - char letters[] = "oizeasbtbq"; - for (int i = 0; i < 10; i++){ - if (c == numbers[i]){ - return letters[i]; + int search_string(const char* heap, const char* needle){ + char pole[5]="abcd"; + for (int i = 0; i < 5; i++){ + printf("%c",pole[i+1]); } } -} \ No newline at end of file + + int read_pizza(struct pizza* item){ + float value = strtof(line,struct pizza); + // Ak je návratová hodnota nula, premena reťazca sa nepodarila. + if (value == 0.0F){ + return 0; + } + item->prize = value; + strcpy(item->name, line); + return 1; + } + + char hacker_script(char c){ + char numbers[] = "0123456789"; + char letters[] = "oizeasbtbq"; + for (int i = 0; i < 10; i++){ + if (tolower(c) == numbers[i]){ + return letters[i]; + } + } + } + +//////////////////////// +// //////// +// /////// ////// +// //////// ////// +// //////// ////// +// ////// ////// +// //// ///////// +// //////////// +// /// /////////// +// //// ////////// +// ///// ///////// +// ////// //////// +// /////// /////// +//////////////////////// \ No newline at end of file