diff --git a/vyhladaj.c b/vyhladaj.c index e69de29..bd3f450 100644 --- a/vyhladaj.c +++ b/vyhladaj.c @@ -0,0 +1,147 @@ +#include +#include +#include + +/* run this program using the console pauser or add your own getch, system("pause") or input loop */ + +#define LINE_SIZE 100 + +struct pizza { + float prize; + char name[LINE_SIZE]; +}; + +int read_pizza(struct pizza* item); +int search_string(const char* heap, const char* needle); +char hacker_script(char c); + +int main(int argc, char *argv[]) { + + printf("Zadaj hladanu surovinu:\n"); + printf("Zadaj jedalny listok:\n"); + + char string[LINE_SIZE]; + memset(string,0,LINE_SIZE); + + char *r = fgets(string,LINE_SIZE,stdin); + if(r != NULL && string[1] != 0){ + char *pos; + if ((pos=strchr(string, '\n')) != NULL) + *pos = '\0'; + //printf("Hladane jedlo: %s",string); + struct pizza item; + int counter = 0; + while(read_pizza(&item)){ + counter += 1; + //int x = strlen(item.name); + //printf("Dlzka %d\n",x); + /*int i; + for(i=0;iprize = value; + strcpy(item->name, line); + return 1; + } + else{ + return 0; + } + } + else{ + return 0; + } + } +} + +char hacker_script(char c){ + + char big_letters[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; + char small_letters[] = "abcdefghijklmnopqrstuvwxyz"; + for (int i = 0; i < 26; i++){ + if (c == big_letters[i]){ + //printf(" Nahradzujem %c za %c\n",big_letters[i],small_letters[i]); + return small_letters[i]; + } + } + + char numbers[] = "0123456789"; + char letters[] = "oizeasbtbq"; + for (int i = 0; i < 10; i++){ + if (c == numbers[i]){ + //printf(" Nahradzujem %c za %c\n",numbers[i],letters[i]); + return letters[i]; + } + } + return '0'; +} + +int search_string(const char* heap, const char* needle){ + + char needle_2[strlen(needle)]; + strcpy(needle_2,needle); + + int a; + for(a=0;a