diff --git a/program.c b/program.c deleted file mode 100644 index a65ec21..0000000 --- a/program.c +++ /dev/null @@ -1,104 +0,0 @@ -#include -#include -#include -#include - -#define LINESIZE 100 -struct pizza{ - char name[LINESIZE]; - float prize; -}; - -int read_pizza(struct pizza* item){ - - char line1[LINESIZE]; - char line2[LINESIZE]; - - memset(line1, 0, LINESIZE); - memset(line2, 0, LINESIZE); - char *l1 = fgets(line1,LINESIZE,stdin); - char *l2 = fgets(line2,LINESIZE,stdin); - float value = strtof(line2, &l2); - if(value == 0.0F){ - return 0; - } - if(l1 != NULL && line1[1] != 0){ - item->prize = value; - strcpy(item->name, line1); - return 1; - } -} - -int search_string(const char* heap, const char* needle){ - int H = strlen(heap); - int N = strlen(needle); - int i; - for(i = 0; i <= H - N; i++){ - int j; - for(j = 0; j < N; j++){ - if(heap[i+j] != needle[j]){ - return -1; - } - if(j = N){ - return i; - } - } - } -} - -char hacker_script(char c){ - if(isupper(c)){ - c = tolower(c); - } - char numbers[] = "0123456789"; - char letters[] = "oizeasbtbq"; - int i; - for (i = 0; i < 10; i++){ - if (c == numbers[i]){ - c = letters[i]; - return c; - } - } -} - -int main(){ - - char key[LINESIZE]; - memset(key,0,LINESIZE); - char* r = fgets(key,LINESIZE,stdin); - - struct pizza jedalny_listok[100]; - struct pizza pomocny[100]; - memset(pomocny, 0, sizeof(struct pizza)*100); - memset(jedalny_listok, 0,sizeof(struct pizza)*100); - struct pizza item; - int counter = 0; - - - while(read_pizza(&item)){ - strcpy(jedalny_listok[counter].name, item.name); - jedalny_listok[counter].prize = item.prize; - counter++; - } - int i, j, f; - for(i = 0; i < counter; i++){ - for(j = 0; j < strlen(jedalny_listok[i].name); j++){ - pomocny[i].name[j] = hacker_script(jedalny_listok[i].name[j]); - //printf("%c", pomocny[i].name[j]); - - } - search_string(pomocny[i].name, key); - if(search_string(pomocny[i].name, key) != -1){ - printf("%s", jedalny_listok[i].name); - printf("%.2f\n", jedalny_listok[i].prize); - printf("Nacitano %d poloziek\n", counter); - return 1; - } - - } - printf("Nacitano %d poloziek\n", counter); - return 1; - -} - -