Advertisement
Guest User

Untitled

a guest
Jun 28th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.06 KB | None | 0 0
  1. #include <iostream.h>
  2. // ororo, gaijin code
  3. // aqrrays for input
  4. bool x1[8];
  5. bool x2[8];
  6. bool x3[8];
  7. bool x4[8];
  8. // arrays for storing result
  9. bool res1[8];
  10. bool res2[8];
  11. bool res3[8];
  12. bool res4[8];
  13. bool res5[8];
  14. // int for exception and prevent closing program
  15. int temp;
  16. // 4-floured m(s?)atanic functions
  17. bool func1(bool, bool, bool, bool);
  18. bool func2(bool, bool, bool, bool);
  19. bool func3(bool, bool, bool, bool);
  20. bool func4(bool, bool, bool, bool);
  21. bool func5(bool, bool, bool, bool);
  22.  
  23. void input();
  24. void doFunctions();
  25. void output();
  26. void pause();
  27.  
  28.  
  29. bool func1(bool a1, bool a2, bool a3, bool a4){
  30. return((not((not(a1) and (not(a2) or a3))) and (not(a3) or a2)) or a4);
  31. }
  32.  
  33. bool func2(bool a1, bool a2, bool a3, bool a4){
  34. return(((not(a1) or not(a2 or(not(a3) or a4) and (not(a4) and a3))) or(a3 and(a2 or (not(a3) or a4)and(not(a4) and a3)))));
  35. }
  36.  
  37. bool func3(bool a1, bool a2, bool a3, bool a4){
  38. return(not(a1) or (not(not(a4) or a3) or a4)and(not(a4) or(not(a2) or a3)));
  39. }
  40.  
  41. bool func4(bool a1, bool a2, bool a3, bool a4){
  42. return(((not(not(a2) or a3) or a3)and(not(a3) or (not(a1) or a2))) and not(a4));
  43. }
  44.  
  45. bool func5(bool a1, bool a2, bool a3, bool a4){
  46. return(a1 or (not((not(a2) or not(a3)) and(a3 or a2) ) and (not(a4) or ((not(a2) or not(a3))and( a3 or a2) ) )));
  47. }
  48.  
  49. void input(){
  50. // input x1
  51. cout<<"enter 8 digits for x1"<<" ";
  52. for(int i=0; i<8; i++){
  53. cin>>x1[i];
  54. }
  55. //input x2
  56. cout<<" "<<"enter 8 digits for x2"<<" ";
  57. for(int i=0; i<8; i++){
  58. cin>>x2[i];
  59. }
  60. //input x3
  61. cout<<" "<<"enter 8 digits for x3"<<" ";
  62. for(int i=0; i<8; i++){
  63. cin>>x3[i];
  64. }
  65. //input x4
  66. cout<<" "<<"enter 8 digits for x4"<<" ";
  67. for(int i=0; i<8; i++){
  68. cin>>x4[i];
  69. }
  70. }
  71.  
  72. void doFunctions(){
  73. for (int i=0; i<8; i++){
  74. res1[i]=func1(x1[i], x2[i], x3[i], x4[i]);
  75. res2[i]=func2(x1[i], x2[i], x3[i], x4[i]);
  76. res3[i]=func3(x1[i], x2[i], x3[i], x4[i]);
  77. res4[i]=func4(x1[i], x2[i], x3[i], x4[i]);
  78. res5[i]=func5(x1[i], x2[i], x3[i], x4[i]);
  79. }
  80. }
  81.  
  82. void output(){
  83. cout<<"function 1"<<endl;
  84. for(int i=0; i<8; i++){
  85. if (res1[i]) {cout<<" 1";} else {cout<<" 0";}
  86. }
  87.  
  88. cout<<endl<<"function 2"<<endl;
  89. for(int i=0; i<8; i++){
  90. if (res2[i]) {cout<<" 1";} else {cout<<" 0";}
  91. }
  92.  
  93. cout<<endl<<"function 3"<<endl;
  94. for(int i=0; i<8; i++){
  95. if (res3[i]) {cout<<" 1";} else {cout<<" 0";}
  96. }
  97.  
  98. cout<<endl<<"function 4"<<endl;
  99. for(int i=0; i<8; i++){
  100. if (res4[i]) {cout<<" 1";} else {cout<<" 0";}
  101. }
  102.  
  103. cout<<endl<<"function 5"<<endl;
  104. for(int i=0; i<8; i++){
  105. if (res5[i]) {cout<<" 1";} else {cout<<" 0";}
  106. }
  107. }
  108.  
  109. void pause(){
  110. cout<<endl<<"input something to exit"<<endl;
  111. cin>>temp;
  112. }
  113.  
  114.  
  115. int main()
  116. {
  117. input();
  118. doFunctions();
  119. output();
  120. pause();
  121.  
  122. return 0;
  123. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement