Advertisement
Guest User

Untitled

a guest
Oct 20th, 2019
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. int checkDivisionZero(HieList* list, HieElem* head, int& err)
  2. {
  3. if (err)//если флаг не ноль, то раннее встречалась ошибка
  4. return 1;
  5. if (head == nullptr)
  6. {
  7. cout << "Error, an empty head element." << endl;
  8. err = 6;
  9. return 1;
  10. }
  11. HieElem* temp = head;
  12. int fl = 0;
  13.  
  14. while(temp != nullptr)
  15. {
  16. if (temp->haveChild == 0)//если элемент содержит указатель на дочерний список
  17. {
  18. return checkDivisionZero(list, temp->child, err);
  19. }
  20. else
  21. {
  22. if ((temp->info) == '/')
  23. {
  24. fl = 1;
  25. temp = temp->next;
  26. continue;
  27. }
  28.  
  29. if (fl == 1)
  30. {
  31. fl = 2;
  32. temp = temp->next;
  33. continue;
  34. }
  35. if (fl == 2)
  36. {
  37. if ((temp->info) == 0)
  38. {
  39. cout << "Error, division by zero!" << endl;
  40. return 1;
  41. }
  42. temp = temp->next;
  43. }
  44. }
  45.  
  46. }
  47. return 0;
  48.  
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement