From ec8dcedf2ae3f5d10fd9c8ac10562916f43f734e Mon Sep 17 00:00:00 2001 From: Bohdan Kapliuk Date: Sun, 29 Sep 2024 15:33:07 +0300 Subject: [PATCH] cv1 --- cv1/program.c | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 66 insertions(+), 1 deletion(-) diff --git a/cv1/program.c b/cv1/program.c index 50ceb88..fa670c4 100644 --- a/cv1/program.c +++ b/cv1/program.c @@ -1 +1,66 @@ -#include stdio.h +#include +#include + +#define LINESIZE 100 +struct pizza { + char price[LINESIZE]; + char name[LINESIZE]; +}; + +int main(){ + char surovina[LINESIZE]; + char vstup[LINESIZE]; + struct pizza menu[LINESIZE]; + char numbers[] = "0123456789"; + char letters[] = "oizeasbtbq"; + printf("Zadaj hladanu surovinu:\n"); + fgets(surovina,LINESIZE,stdin); + printf("Zadaj jedalny listok:\n"); + int count = 0; + while (count < LINESIZE) { + if (fgets(vstup, LINESIZE, stdin)) { + vstup[strcspn(vstup, "\n")] = '\0'; + if (strlen(vstup) == 0) { + break; + } + strcpy(menu[count].name, vstup); + } else { + break; + } + + if (fgets(vstup, LINESIZE, stdin)) { + vstup[strcspn(vstup, "\n")] = '\0'; + if (strlen(vstup) == 0) { + break; + } + strcpy(menu[count].price, vstup); + } else { + break; + } + count++; + } + for(int i = 0; i <= count;i++){ + for(int j = 0; j <= strlen(menu[i].name);j++){ + for(int x = 0; x <= 11;x++){ + if(menu[i].name[j] == numbers[x]){ + menu[i].name[j] = letters[x]; + } + } + } + } + int odpoved; + for(int i = 0; i <= count;i++){ + for(int j = 0; j <= strlen(menu[i].name);j++){ + for(int x = 0; x <= strlen(surovina);x++){ + if(surovina[x] != menu[i].name[j]){ + break; + } + odpoved = i; + } + } + } + printf("%s\n", menu[odpoved].name); + printf("%s\n", menu[odpoved].price); + printf("Nacitanych %d poloziek.\n", count); + return 0; +} \ No newline at end of file