76 lines
2.1 KiB
C
76 lines
2.1 KiB
C
#include <stdio.h>
|
|
#include <string.h>
|
|
#include <stdlib.h>
|
|
#include <ctype.h>
|
|
|
|
#define LINESIZE 100
|
|
struct pizza {
|
|
char price[LINESIZE];
|
|
char name[LINESIZE];
|
|
};
|
|
|
|
int main(){
|
|
char surovina[LINESIZE];
|
|
char vstup[LINESIZE];
|
|
struct pizza menu[LINESIZE];
|
|
struct pizza menu1[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);
|
|
strcpy(menu1[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);
|
|
strcpy(menu1[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];
|
|
}
|
|
if(isupper(menu[i].name[j])){
|
|
menu[i].name[j] = tolower(menu[i].name[j]);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
int ddfd = strcspn(menu[1].name, " ");
|
|
for(int i = 0; i <= count;i++){
|
|
int y = 0;
|
|
for(int x = 0; x <= strlen(surovina);x++){
|
|
if(surovina[x] != menu[i].name[x] && surovina[x] != menu[i].name[(strcspn(menu[i].name, " ") + x)+1]){
|
|
break;
|
|
}
|
|
y = 1;
|
|
}
|
|
if(y == 1){
|
|
printf("%s\n", menu1[i].name);
|
|
float number = strtof(menu1[i].price, NULL);
|
|
printf("%.2f\n", number);
|
|
}
|
|
}
|
|
printf("Nacitanych %d poloziek.\n", count);
|
|
return 0;
|
|
} |