Advertisement
rabbitekk312

Untitled

Feb 12th, 2021
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. echo "Operatory logiczne mozliwe do uzycia ( Koniunkcja, alternatywa, implikacja, rownowaznosc )"
  4.  
  5. i=0
  6. p=0
  7. numzm=0
  8. tab=( )
  9. tabvalue=( )
  10. expression=""
  11.  
  12. pobierz_wyrazenie() {
  13. echo "Wprowadz wyrazenie logiczne:"
  14. read expression;
  15. }
  16.  
  17. # {
  18.  
  19. testowanie_tautologi() {
  20. for I in tab
  21. do
  22. if [ !${#tab[i]} ]
  23. then
  24. p=1;
  25. fi
  26. done
  27.  
  28. if [ !p ]
  29. then
  30. return 1;
  31. fi
  32.  
  33. for I in tab
  34. do
  35. if [ ${#tab[i]} ]
  36. then
  37. p=1;
  38. fi
  39. done
  40.  
  41. if [ !p ]
  42. then
  43. return 2;
  44. fi
  45.  
  46. return 0;
  47.  
  48. # }
  49.  
  50. }
  51.  
  52. # PROGRAM !
  53.  
  54. zm1=0
  55.  
  56. #pobierz_wyrazenie expression
  57. if [ zm1==1 ]
  58. then
  59. pobierz_wyrazenie expression
  60. fi
  61.  
  62. if [ testowanie_tautologi tabvalue numzm == 1 ]
  63. then
  64. echo "Podane Wyrazenie jest tautologia"
  65. elif [ testowanie_tautologi tabvalue numzm == 2 ]
  66. then
  67. echo "Podane wyrazenie nie jest tautologia"
  68. else
  69. echo "Podane Wyrazenie jest niewlasciwe"
  70.  
  71. if [ zm1 != 2 ]
  72. then
  73. echo "Prosze podac dokladnie jedno wyrazenie logiczne"
  74. return 0;
  75. fi
  76.  
  77. if [ testowanie_tautologi tabvalue numzm == 1 ]
  78. then
  79. echo "Podane wyrazenie jest tautologia"
  80. elif [ testowanie_tautologi tabvalue numzm == 2 ]
  81. then
  82. echo "Podane wyrazenie jest sprzeczne"
  83. else
  84. echo "Podane wyrazenie jest niewlasciwe"
  85. fi
  86. return 0;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement