Update cv7/program.c
This commit is contained in:
		
							parent
							
								
									ad35043de4
								
							
						
					
					
						commit
						e3952af035
					
				| @ -97,22 +97,24 @@ void ask_question(Node *node) { | |||||||
| 
 | 
 | ||||||
| int main() { | int main() { | ||||||
|     printf("Expert z bufetu to vie.\n"); |     printf("Expert z bufetu to vie.\n"); | ||||||
| 
 |     printf("Pozna 2 druhov ovocia a zeleniny.\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("Odpovedajte 'a' pre prvu moznost alebo 'n' pre druhu moznost.\n"); |     printf("Odpovedajte 'a' pre prvu moznost alebo 'n' pre druhu moznost.\n"); | ||||||
| 
 | 
 | ||||||
|     if (root) { |     char input[50]; | ||||||
|         ask_question(root); |     int understood = 0;  // To track if the response was understood
 | ||||||
|     } |  | ||||||
|      |  | ||||||
|     free_tree(root); |  | ||||||
| 
 | 
 | ||||||
|     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