1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88
|
#include <iostream.h>
#include <conio.h>
int dat(long int jd)
{ long int z, a, b, d;
int w, x, c, e, f;
z=jd;
w=(z-1867216.25)/36524.25;
x=w/4;
a=z+1+w-x;
b=a+1524;
c=(b-122.1)/365.25;
d=365.25*c;
e=(b-d)/30.6001;
f=30.6001*e;
return b-d-f;
}
int mont(long int jd)
{
long int z, a, b, d;
int w, x, c, e, f;
z=jd;
w=(z-1867216.25)/36524.25;
x=w/4;
a=z+1+w-x;
b=a+1524;
c=(b-122.1)/365.25;
d=365.25*c;
e=(b-d)/30.6001;
if(e<=13)
return e-1;
else
return e-13;
}
int yea(long int jd)
{
long int z, a, b, d;
int w, x, c, e, f;
z=jd;
w=(z-1867216.25)/36524.25;
x=w/4;
a=z+1+w-x;
b=a+1524;
c=(b-122.1)/365.25;
d=365.25*c;
e=(b-d)/30.6001;
if(e>13)
return c-4715;
else
return c-4716;
}
long int julian(int d, int m, int y)
{
int a, b, c, f;
long int e, jd;
if(m==1||m==2)
{
y=y-1;
m=m+12;
}
a=y/100;
b=a/4;
c=2-a+b;
e=365.25*(y+4716);
f=30.6001*(m+1);
jd=c+d+e+f-1524;
return jd;
}
long int add(long int jd, int days)
{
return jd=jd+days;
}
void main()
{
clrscr();
long int jd;
int date, month, year, days, ndate, nmonth, nyear;
cout<<" Enter the date (d, m, y)";
cin>>date>>month>>year;
cout<<"Enter days to add";
cin>>days;
jd=julian(date, month, year);
jd=add(jd, days);
ndate=dat(jd);
nmonth=mont(jd);
nyear=yea(jd);
cout<<"\n New date=:"<<ndate<<" "<<nmonth<<" "<<nyear;
getch();
}
|