diff --git a/cv1/a.out b/cv1/a.out new file mode 100755 index 0000000..f7ad0bb Binary files /dev/null and b/cv1/a.out differ diff --git a/cv1/program.c b/cv1/program.c new file mode 100644 index 0000000..8277c15 --- /dev/null +++ b/cv1/program.c @@ -0,0 +1,106 @@ +#include +#include +#include +#include +#define SIZE 100 + +struct pizza{ + float price; + char name[SIZE]; +}; + + +char hacker_script(char c); +int read_pizza(struct pizza* pizza1); +int search(char *needle, char* heap); +char* upgrade_string(char* param); + +int main(){ + puts("Zadaj hladanu surovinu:"); + char needle[SIZE]; + memset(needle,0,SIZE); + fgets(needle,SIZE,stdin); + needle[strlen(needle)-1]='\0'; + + struct pizza list[30]; + int index =0; + puts("Zadaj jedalny listok:"); + while(read_pizza(&list[index])){ + index++; + } + + for(int i =0;iname,SIZE,stdin)==NULL)return 0; + if(pizza1->name[0]=='\n'){ + return 0; + } + pizza1->name[strlen(pizza1->name)-1]='\0'; + + char* price = calloc(SIZE,sizeof(char)); + fgets(price,SIZE,stdin); + price[strlen(price)-1]='\0'; + + sscanf(price,"%f",&(pizza1->price)); + return 1; +} + + +char hacker_script(char c){ + char numbers[] = "0123456789"; + char letters[] = "oizeasbtbq"; + int i; + for (i = 0; i < 10; i++){ + if (c == numbers[i]){ + return letters[i]; + } + } + return 0; +} + + +int search(char *needle,char *heap){ + char* Needle = upgrade_string(needle); + char* Heap = upgrade_string(heap); + + int M = strlen(Needle); + int N = strlen(Heap); + for(int i =0;i<=N-M;i++){ + int j; + for(j=0;j