This commit is contained in:
Bohdan Kapliuk 2024-09-29 15:33:07 +03:00
parent 2f8f3307d3
commit ec8dcedf2a

View File

@ -1 +1,66 @@
#include stdio.h
#include <stdio.h>
#include <string.h>
#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;
}