Update cv1/program.c

This commit is contained in:
Yurii Chechur 2024-10-02 18:46:51 +00:00
parent 053a97a118
commit c697731ab5

View File

@ -20,10 +20,11 @@ void normalize(char* str) {
case 'e': str[i] = '3'; break;
case 'a': str[i] = '4'; break;
case 's': str[i] = '5'; break;
case 'b': str[i] = '6'; break;
case 'd': str[i] = '6'; break; // 'b' mapped to '6'
case 't': str[i] = '7'; break;
case 'g': str[i] = '9'; break;
case 'b': str[i] = '8'; break;
case 'q': str[i] = '9'; break;
// We keep 'r', 'y', 'n', and 'd' unchanged to ensure proper matching
default: break;
}
}
@ -81,6 +82,7 @@ int main(void) {
// Search for and print found dishes
int found = 0;
for (int i = 0; i < item_count; i++) {
// Perform a direct search for the normalized dish against the normalized search string
if (strstr(menu[i].dish, search_string) != NULL) { // Check if search_string is in dish
printf("%s\n%.2f\n", menu[i].dish, menu[i].price);
found = 1; // At least one dish found