Advertisement
Guest User

Untitled

a guest
Nov 13th, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.75 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. long int transforma_data_zile(int Z,int L,int A){
  5.  
  6. long int zile_curente=Z,ani_bisecti,bisect=0;
  7. L--;
  8. while(L>0){
  9. if(L<8){
  10. if(L%2==1){
  11. zile_curente=zile_curente+31;
  12. }
  13. else{
  14. if(L==2){
  15. zile_curente=zile_curente+28;
  16. }
  17. else{
  18. zile_curente=zile_curente+30;
  19. }
  20. }
  21. }
  22. else{
  23. if(L%2==1){
  24. zile_curente=zile_curente+30;
  25. }
  26. else{
  27. zile_curente=zile_curente+31;
  28. }
  29. }
  30.  
  31. L--;
  32. }
  33. //pentru a adauga ziua de 29 feb pentru ani bisecti
  34. if(A%4==0&&zile_curente>59){
  35. zile_curente++;
  36. bisect=1;
  37. }
  38. //adaugam 1 pentru anul bisect 1900
  39. if(bisect==1){
  40. ani_bisecti=A/4;
  41. }
  42. else{
  43. ani_bisecti=A/4+1;
  44. }
  45.  
  46. zile_curente=zile_curente+A*365+ani_bisecti;
  47.  
  48. return zile_curente;
  49. }
  50. void transforma_zile_data(long int zile_curente){
  51. int Z,L,A,bisect=0,ani_bisecti;
  52. A=zile_curente/365;
  53. zile_curente=zile_curente%365;
  54. if(A%4==0){
  55. ani_bisecti=A/4;
  56. bisect=1;
  57. }
  58. else{
  59. ani_bisecti=A/4+1;
  60. bisect=0;
  61. }
  62. zile_curente=zile_curente-ani_bisecti;
  63.  
  64. L=zile_curente/30+1;
  65. Z=zile_curente%30;
  66. if(L>=3&&Z>=0){
  67.  
  68. if(bisect==0){
  69. Z=Z+2;
  70. }
  71. else{
  72. Z=Z+1;
  73. }
  74.  
  75. }
  76. if(L<=8){
  77. Z=Z-L/2;
  78. }
  79. else{
  80. Z=Z-(L/2+1);
  81. }
  82. if(Z>30){
  83.  
  84. if(L<8){
  85. if(L%2==1){
  86. Z=Z-31;
  87. }
  88. else{
  89. Z=Z-30;
  90. }
  91. }
  92. else{
  93. if(L%2==1){
  94. Z=Z-30;
  95. }
  96. else{
  97. Z=Z-31;
  98. }
  99. }
  100.  
  101. }
  102. else if(Z<=0){
  103. if(L>1){
  104. L--;
  105. if(L<8){
  106. if(L%2==1){
  107. Z=Z+31;
  108. }
  109. else{
  110. Z=Z+30;
  111. }
  112. }
  113. else{
  114. if(L%2==1){
  115. Z=Z+30;
  116. }
  117. else{
  118. Z=Z+31;
  119. }
  120. }
  121. }
  122. else{
  123. A--;
  124. L=12;
  125. Z=31+Z;
  126. }
  127.  
  128. }
  129. cout<<Z<<" "<<L<<" "<<A+1900;
  130.  
  131. }
  132. int main(){
  133.  
  134. long int Z,L,A,nr,ani_dif,zile_curente,zile_dif,zile_bis=0,feb_bisect,zile_an=365;
  135. cin>>Z>>L>>A;
  136. cin>>nr;
  137. A=A-1900;
  138. zile_curente=transforma_data_zile(Z,L,A);
  139. zile_curente=zile_curente+nr;
  140. transforma_zile_data(zile_curente);
  141.  
  142. return 0;
  143. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement