Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- long int transforma_data_zile(int Z,int L,int A){
- long int zile_curente=Z,ani_bisecti,bisect=0;
- L--;
- while(L>0){
- if(L<8){
- if(L%2==1){
- zile_curente=zile_curente+31;
- }
- else{
- if(L==2){
- zile_curente=zile_curente+28;
- }
- else{
- zile_curente=zile_curente+30;
- }
- }
- }
- else{
- if(L%2==1){
- zile_curente=zile_curente+30;
- }
- else{
- zile_curente=zile_curente+31;
- }
- }
- L--;
- }
- //pentru a adauga ziua de 29 feb pentru ani bisecti
- if(A%4==0&&zile_curente>59){
- zile_curente++;
- bisect=1;
- }
- //adaugam 1 pentru anul bisect 1900
- if(bisect==1){
- ani_bisecti=A/4;
- }
- else{
- ani_bisecti=A/4+1;
- }
- zile_curente=zile_curente+A*365+ani_bisecti;
- return zile_curente;
- }
- void transforma_zile_data(long int zile_curente){
- int Z,L,A,bisect=0,ani_bisecti;
- A=zile_curente/365;
- zile_curente=zile_curente%365;
- if(A%4==0){
- ani_bisecti=A/4;
- bisect=1;
- }
- else{
- ani_bisecti=A/4+1;
- bisect=0;
- }
- zile_curente=zile_curente-ani_bisecti;
- L=zile_curente/30+1;
- Z=zile_curente%30;
- if(L>=3&&Z>=0){
- if(bisect==0){
- Z=Z+2;
- }
- else{
- Z=Z+1;
- }
- }
- if(L<=8){
- Z=Z-L/2;
- }
- else{
- Z=Z-(L/2+1);
- }
- if(Z>30){
- if(L<8){
- if(L%2==1){
- Z=Z-31;
- }
- else{
- Z=Z-30;
- }
- }
- else{
- if(L%2==1){
- Z=Z-30;
- }
- else{
- Z=Z-31;
- }
- }
- }
- else if(Z<=0){
- if(L>1){
- L--;
- if(L<8){
- if(L%2==1){
- Z=Z+31;
- }
- else{
- Z=Z+30;
- }
- }
- else{
- if(L%2==1){
- Z=Z+30;
- }
- else{
- Z=Z+31;
- }
- }
- }
- else{
- A--;
- L=12;
- Z=31+Z;
- }
- }
- cout<<Z<<" "<<L<<" "<<A+1900;
- }
- int main(){
- long int Z,L,A,nr,ani_dif,zile_curente,zile_dif,zile_bis=0,feb_bisect,zile_an=365;
- cin>>Z>>L>>A;
- cin>>nr;
- A=A-1900;
- zile_curente=transforma_data_zile(Z,L,A);
- zile_curente=zile_curente+nr;
- transforma_zile_data(zile_curente);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement