a
This commit is contained in:
parent
0a2386f3cf
commit
f3f60d509d
@ -1,4 +1,64 @@
|
||||
#include <stdio.h>
|
||||
int main(){
|
||||
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#define LINE_SIZE 200
|
||||
|
||||
// meni cisla na znaky a aj velke na male
|
||||
void normalize(char *z) {
|
||||
char cis[] = "013456789";
|
||||
char pis[] = "oieasgtbq";
|
||||
|
||||
for (int i = 0; z[i]; i++) {
|
||||
char x = tolower(z[i]);
|
||||
|
||||
|
||||
int found = 0;
|
||||
for (int j = 0; j < 9; j++) {
|
||||
if (x == cis[j]) {
|
||||
z[i] = pis[j];
|
||||
found = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//na male pismeno
|
||||
if (!found) {
|
||||
z[i] = x;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int main() {
|
||||
char h[LINE_SIZE];
|
||||
char line[LINE_SIZE];
|
||||
char j[LINE_SIZE];
|
||||
char price[LINE_SIZE];
|
||||
int count = 0;
|
||||
|
||||
printf("Zadaj hladanu surovinu:\n");
|
||||
if (!fgets(h, LINE_SIZE, stdin)) return 0;
|
||||
h[strcspn(h, "\n")] = 0;
|
||||
normalize(h);
|
||||
|
||||
printf("Zadaj jedalny listok:\n");
|
||||
while (1) {
|
||||
if (!fgets(j, LINE_SIZE, stdin)) break;
|
||||
j[strcspn(j, "\n")] = 0;
|
||||
if (strlen(j) == 0) break;
|
||||
if (!fgets(price, LINE_SIZE, stdin)) break;
|
||||
price[strcspn(price, "\n")] = 0;
|
||||
char norm_dish[LINE_SIZE];
|
||||
strcpy(norm_dish, j);
|
||||
normalize(norm_dish);
|
||||
if (strstr(norm_dish, h) != NULL) {
|
||||
printf("%s\n", j);
|
||||
printf("%s\n", price);
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
printf("Nacitanych %d poloziek.\n", count);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user