26
This commit is contained in:
		
							parent
							
								
									e6fcb73d14
								
							
						
					
					
						commit
						bbb91099f3
					
				| @ -49,29 +49,28 @@ int count_products(Node *node) { | ||||
| 
 | ||||
| void run_expert_system(Node *node) { | ||||
|     while (node) { | ||||
|         printf("Odpovedajte 'a' pre prvu moznost alebo 'n' pre druhu moznost.\n"); | ||||
|         printf("%s\n", node->text); | ||||
| 
 | ||||
|         // Print the answer if it's a leaf node.
 | ||||
|         if (!node->yes && !node->no) { | ||||
|             printf("*%s\n", node->text); | ||||
|         if (!node->yes && !node->no) {  // Если это листовой узел
 | ||||
|             printf("*%s\n", node->text); // Выводим только ответ
 | ||||
|             printf("Koniec\n"); | ||||
|             return; | ||||
|         } | ||||
| 
 | ||||
|         printf("Odpovedajte 'a' pre prvu moznost alebo 'n' pre druhu moznost.\n"); | ||||
|         printf("%s\n", node->text); | ||||
| 
 | ||||
|         char answer; | ||||
|         if (scanf(" %c", &answer) != 1) { | ||||
|             printf("Koniec\n"); // Incorrect input, termination
 | ||||
|             printf("Koniec\n"); // Неправильный ввод, завершение
 | ||||
|             return; | ||||
|         } | ||||
| 
 | ||||
|         // Move to the next node based on user's answer
 | ||||
|         // Переход к следующему узлу в зависимости от ответа пользователя
 | ||||
|         if (answer == 'a') { | ||||
|             node = node->yes; | ||||
|         } else if (answer == 'n') { | ||||
|             node = node->no; | ||||
|         } else { | ||||
|             printf("Koniec\n"); // Incorrect answer, termination
 | ||||
|             printf("Koniec\n"); // Неправильный ответ, завершение
 | ||||
|             return; | ||||
|         } | ||||
|     } | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user