38 lines
939 B
C
38 lines
939 B
C
#include <stdio.h>
|
|
#include <string.h>
|
|
#include <ctype.h>
|
|
|
|
char convert_to_normal(char ch) {
|
|
switch (ch) {
|
|
case '0': return 'o';
|
|
case '1': return 'i';
|
|
case '2': return 'z';
|
|
case '3': return 'e';
|
|
case '4': return 'a';
|
|
case '5': return 's';
|
|
case '6': return 'b';
|
|
case '7': return 't';
|
|
case '8': return 'b';
|
|
case '9': return 'q';
|
|
default: return tolower(ch);
|
|
}
|
|
}
|
|
|
|
int contains_substring(char *food_name, char *ingredient) {
|
|
int len_food = strlen(food_name);
|
|
int len_ing = strlen(ingredient);
|
|
int i, j;
|
|
|
|
for (i = 0; i <= len_food - len_ing; i++) {
|
|
int found = 1;
|
|
for (j = 0; j < len_ing; j++) {
|
|
if (convert_to_normal(food_name[i + j]) != convert_to_normal(ingredient[j])) {
|
|
found = 0;
|
|
break;
|
|
}
|
|
}
|
|
if (found) return 1;
|
|
}
|
|
return 0;
|
|
}
|