This commit is contained in:
Matej Hajduk 2025-09-24 14:29:03 +02:00
parent f3f60d509d
commit 12235c8914

View File

@ -6,23 +6,20 @@
// meni cisla na znaky a aj velke na male
void normalize(char *z) {
char cis[] = "013456789";
char pis[] = "oieasgtbq";
char cis[] = "0123456789";
char pis[] = "oizeasgtbq";
for (int i = 0; z[i]; i++) {
char x = tolower(z[i]);
char x = tolower((unsigned char)z[i]);
int found = 0;
for (int j = 0; j < 9; j++) {
for (int j = 0; j < 10; j++) {
if (x == cis[j]) {
z[i] = pis[j];
found = 1;
break;
}
}
//na male pismeno
if (!found) {
z[i] = x;
}
@ -31,7 +28,6 @@ void normalize(char *z) {
int main() {
char h[LINE_SIZE];
char line[LINE_SIZE];
char j[LINE_SIZE];
char price[LINE_SIZE];
int count = 0;
@ -46,15 +42,19 @@ int main() {
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;
count++; // počítame všetky položky
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++;
}
}