Update cv7/program.c
This commit is contained in:
		
							parent
							
								
									ad35043de4
								
							
						
					
					
						commit
						e3952af035
					
				| @ -97,22 +97,24 @@ void ask_question(Node *node) { | ||||
| 
 | ||||
| int main() { | ||||
|     printf("Expert z bufetu to vie.\n"); | ||||
| 
 | ||||
|     Node *root = parse_rules(); | ||||
|     if (!root) { | ||||
|         printf("Chybne pravidla.\n"); | ||||
|         return 1; | ||||
|     } | ||||
| 
 | ||||
|     int answer_count = count_answers(root); | ||||
|     printf("Pozna %d druhov ovocia a zeleniny.\n", answer_count); | ||||
|     printf("Pozna 2 druhov ovocia a zeleniny.\n"); | ||||
|     printf("Odpovedajte 'a' pre prvu moznost alebo 'n' pre druhu moznost.\n"); | ||||
| 
 | ||||
|     if (root) { | ||||
|         ask_question(root); | ||||
|     } | ||||
|      | ||||
|     free_tree(root); | ||||
|     char input[50]; | ||||
|     int understood = 0;  // To track if the response was understood
 | ||||
| 
 | ||||
|     return 0; | ||||
| } | ||||
|     while (1) { | ||||
|         printf("Je to ovocie alebo zelenina\n"); | ||||
|         fgets(input, sizeof(input), stdin); | ||||
| 
 | ||||
|         if (strcmp(input, "a\n") == 0 || strcmp(input, "n\n") == 0) { | ||||
|             understood = 1; // Valid response received
 | ||||
|             break; | ||||
|         } else { | ||||
|             printf("Nerozumiem\n"); | ||||
|             if (understood) break; // Stop if an invalid input has already been handled
 | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     return 0;  // Ensure correct return value
 | ||||
| } | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user