diff --git a/du1/program b/du1/program new file mode 100755 index 0000000..790b74a Binary files /dev/null and b/du1/program differ diff --git a/du1/program.c b/du1/program.c new file mode 100644 index 0000000..f3d90e1 --- /dev/null +++ b/du1/program.c @@ -0,0 +1,94 @@ +#include +#include +#include +#include + +#define LINE_SIZE 100 +#define MAXIT 100 + +struct pizza{ + float prize; + char name[LINE_SIZE]; +}; + +char hacker_script(char c){ + c = tolower((unsigned char)c); + switch(c){ + case '0': return 'o'; + case '1': return 'i'; + case '2': return 'z'; + case '3': return 'e'; + case '4': return 'a'; + case '5': return 's'; + case '6': return 'b'; + case '7': return 't'; + case '8': return 'b'; + case '9': return 'q'; + default: return c;} +} + + +void normalize(const char *source, char *dest){ + int i =0; + while(source[i]!='\0'){ + dest[i]= hacker_script(source[i]); + i++; + } + dest[i]='\0'; +} + + + + + + +int read_pizza(struct pizza *item){ + char line_1[LINE_SIZE]; + char line_2[LINE_SIZE]; + + if (fgets(line_1,LINE_SIZE,stdin)==NULL) return 0; + if (fgets(line_2,LINE_SIZE,stdin)==NULL) return 0; + + line_1[strcspn(line_1,"\n")] = '\0'; + line_2[strcspn(line_2,"\n")] = '\0'; + + float price = 0.0; + if (sscanf(line_2, "%f", &price)!=1) return 0; + + strcpy(item->name, line_1); + item->prize = price; + + return 1; +} + + +int main(){ + char search[LINE_SIZE]; + char normal_search[LINE_SIZE]; + + struct pizza list[MAXIT]; + int cnt = 0; + + printf("Zadaj hladanu surovinu:\n"); + if (fgets(search, LINE_SIZE, stdin)==NULL) return 0; + search[strcspn(search,"\n")] = '\0'; + + normalize(search, normal_search); + + printf("Zadaj jedalny listok:\n"); + + + while(cnt