Update cv1/program.c
This commit is contained in:
parent
053a97a118
commit
c697731ab5
@ -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;
|
||||
}
|
||||
}
|
||||
@ -74,13 +75,14 @@ int main(void) {
|
||||
}
|
||||
|
||||
// Normalize the dish name
|
||||
normalize(item.dish);
|
||||
normalize(item.dish);
|
||||
menu[item_count++] = item; // Add item to menu
|
||||
}
|
||||
|
||||
// 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
|
||||
|
Loading…
Reference in New Issue
Block a user