Advertisement
Guest User

Untitled

a guest
Dec 8th, 2016
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.22 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4. void howMuchUnshift(int a[],int size,int Unshift)
  5. {
  6. cout<<"if you want unshift write any numbers else 0"<<endl;
  7. for(int i=0;i<5;i++)
  8. {
  9. cin>>Unshift;
  10. if(Unshift==0)
  11. {
  12. i=5;
  13. }
  14. if(a[i]==0)
  15. {
  16. a[i]=Unshift;
  17. }
  18. else
  19. {
  20. i=5;
  21. if(Unshift!=0)
  22. {
  23. cout<<"error in number "<<Unshift<<endl;
  24. }
  25. }
  26. }
  27. for(int i=0;i<5;i++)
  28. {
  29. cout<<a[i]<<" ";
  30. }
  31. cout<<endl;
  32.  
  33.  
  34.  
  35. }
  36. void howShift(int a[],int size,int shift)
  37. {
  38. cout<<"if you want shift write number 1 else 0"<<endl;
  39. for(int i=0;i<5;i++)
  40. {
  41. cin>>shift;
  42. if(shift==0)
  43. {
  44. i=5;
  45. }
  46. if(a[i]!=0)
  47. {
  48. a[i]=0;
  49. }
  50. }
  51. for(int i=0;i<5;i++)
  52. {
  53. cout<<a[i]<<" ";
  54. }
  55. cout<<endl;
  56.  
  57.  
  58. }
  59. void howPop(int a[],int size,int pop)
  60. {
  61. cout<<"if you want pop write number 1 else 0"<<endl;
  62. for(int i=4;i>-1;i--)
  63. {
  64. cin>>pop;
  65. if(pop==0)
  66. {
  67. i=-1;
  68. }
  69. if(a[i]!=0)
  70. {
  71. a[i]=0;
  72. }
  73. }
  74. for(int i=0;i<5;i++)
  75. {
  76. cout<<a[i]<<" ";
  77. }
  78. cout<<endl;
  79.  
  80. }
  81. void howPush(int a[],int size,int push)
  82. {
  83. cout<<"if you want push write any number else 0"<<endl;
  84. for(int i=4;i>-1;i--)
  85. {
  86. cin>>push;
  87. if(push==0)
  88. {
  89. i=0;
  90. }
  91. if(a[i]==0)
  92. {
  93. a[i]=push;
  94. }
  95. else
  96. {
  97. i=0;
  98. if(push!=0)
  99. {
  100. cout<<"error in number "<<push<<endl;
  101. }
  102. }
  103. }
  104. for(int i=0;i<5;i++)
  105. {
  106. cout<<a[i]<<" ";
  107. }
  108. cout<<endl;
  109.  
  110. }
  111. void obnulit(int a[],int size)
  112. {
  113. for(int i=0;i<5;i++)
  114. {
  115. a[i]=0;
  116. }
  117. }
  118. int main()
  119. {
  120. int size=5;
  121. int a[size];
  122. int Unshift=0;
  123. int shift=0;
  124. int push=0;
  125. int pop=0;
  126. while(1==1)
  127. {
  128. obnulit(a,size);
  129. howMuchUnshift(a,size,Unshift);
  130. howShift(a,size,shift);
  131. howPop(a,size,pop);
  132. howPush(a,size,push);
  133. }
  134.  
  135.  
  136.  
  137. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement