Advertisement
Guest User

Untitled

a guest
Dec 9th, 2019
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.85 KB | None | 0 0
  1. #ifndef SAT
  2. #define SAT
  3. #include <iostream>
  4. using namespace std;
  5. class Vreme{
  6. private:
  7. int h,m,s;
  8. int ph,pm,ps;
  9. int th,tm,ts;
  10. int qh,qm,qs,q;
  11. public:
  12. Vreme(int hh, int mm, int ss){ h=hh; m=mm; s=ss; ph=hh; pm=mm; ps=ss;qh=0;qm=0;qs=0;q=0;}
  13.  
  14. int GetH() const{ return h;}
  15. int GetM() const{ return m;}
  16. int GetS() const{ return s;}
  17.  
  18. int GetPH() const{ return ph;}
  19. int GetPM() const{ return pm;}
  20. int GetPS() const{ return ps;}
  21.  
  22. void SetH(int hh) {h=hh;}
  23. void SetM(int mm) {m=mm;}
  24. void SetS(int ss) {s=ss;}
  25.  
  26. int GetTH() const{ return th;}
  27. int GetTM() const{ return tm;}
  28. int GetTS() const{ return ts;}
  29.  
  30. bool budi(){
  31. int i=0;
  32. if(h==6)i++;
  33. if(m==30)i++;
  34. if(s==0)i++;
  35. if(i==3)return(true);
  36. else return(false);
  37.  
  38. }
  39. bool spavaj(){
  40. int i=0;
  41. if(h==23)i++;
  42. if(m==0)i++;
  43. if(s==0)i++;
  44. if(i==3)return(true);
  45. else return(false);
  46. };
  47.  
  48. void DodatV(int hh, int mm, int ss){
  49. h=h+hh;
  50. m=m+mm;
  51. s=s+ss;
  52. q++;
  53. do{
  54. if(s>=60){m++;s=s-60,qs++;
  55. }
  56. if(m>=60){h++;m=m-60,qm++;
  57. }
  58. if(h>=24)h=h-24,qh++;
  59.  
  60. }while(h>23&m>59&s>59);
  61.  
  62. }
  63.  
  64.  
  65. void OduzetV(int hh, int mm, int ss){
  66. h=h-hh;
  67. m=m-mm;
  68. s=s-ss;
  69. q--;
  70. do{
  71. if(s<0){m--;s=s+60,qs--;
  72. }
  73. if(m<0){h--;m=m+60,qm--;
  74. }
  75. if(m<0)h=h-1,qh--;
  76. if(h<0)h=-1*h;
  77.  
  78. }while(s<0&m<0&h<0);
  79.  
  80. }
  81.  
  82. void prosloV(){
  83. int i=0;
  84. if(q>0)i++;
  85. if(qh>0)i++;
  86. if(qm>0)i++;
  87. if(qs>0)i++;
  88.  
  89. if(q<0)i--;
  90. if(qh<0)i--;
  91. if(qm<0)i--;
  92. if(qs<0)i--;
  93.  
  94.  
  95. if(i>0){
  96. th=0;
  97. tm=0;
  98. ts=0;
  99. if(ph>h){th=ph-(h+24);
  100. }
  101. else {th=ph-h;
  102. }
  103. tm=pm-m;
  104. ts=ps-s;
  105. do{
  106. if(ts>=60){tm++;ts=ts-60;
  107. }
  108. if(tm>=60){th++;tm=tm-60;
  109. }
  110. if(th>=23)th=th-23;
  111.  
  112. }while(ts>23&tm>59&th>59);
  113. };
  114. if(i<0){
  115. th=0;
  116. tm=0;
  117. ts=0;
  118. if(ph>h){th=(h+24)-ph;
  119. }
  120. else {th=ph+h;
  121. }
  122. tm=pm+m;
  123. ts=ps+s;
  124. do{
  125. if(ts<0){tm--;ts=ts+60;
  126. }
  127. if(tm<0){th--;tm=tm+60;
  128. }
  129. if(tm<0)th=th-1;
  130. if(th<0)th=-1*th;
  131. }while(ts<0&tm<0&th<0);
  132. };
  133. if(i==0){
  134. th=0;
  135. tm=0;
  136. ts=0;
  137. }
  138.  
  139. }
  140.  
  141.  
  142. void kolikoPV(int hh,int mm,int ss){
  143. th=0;
  144. tm=0;
  145. ts=0;
  146. th=hh+h;
  147. tm=mm+m;
  148. ts=ss+s;
  149. do{
  150. if(ts>=60){tm++;ts=ts-60;
  151. }
  152. if(tm>=60){th++;tm=tm-60;
  153. }
  154. if(th>=24)th=th-24;
  155.  
  156. }while(ts>59&tm>59&th>23);
  157.  
  158. }
  159.  
  160.  
  161. void kolikoUPV(int hh,int mm,int ss){
  162. th=0;
  163. tm=0;
  164. ts=0;
  165. th=hh-h;
  166. tm=mm-m;
  167. ts=ss-s;
  168. do{
  169. if(ts<0){tm--;ts=ts+60;
  170. }
  171. if(tm<0){th--;tm=tm+60;
  172. }
  173. if(tm<0)th=th-1;
  174. if(th<0)th=-1*th;
  175. }while(ts<0&tm<0&th<0);
  176.  
  177. }
  178.  
  179. };
  180. #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement