该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
我这里有自己写的源程序:
#include
#include
struct data
{
int year1;
int specialmonth;
int month1[13];
};
struct day{
int year2;
int month2;
int day2;
};
int dis_day1(struct day *op,int *p)
{
int n=0,x;
n+=(op->year2-1980)*365;
for(x=1980;xyear2;x++)
if((x%4==0&&x%100!=0)||(x%100==0&&x%400==0))n+=1;
for(x=1;xmonth2);x++)
n+=*(p+x-1);
x=op->year2;
if(((x%4==0&&x%100!=0)||(x%100==0&&x%400==0))&&op->month2>2)n+=1;
n+=(op->day2-1);
return n;
}
int dis_day2(struct day *op,struct data *p)
{
int n=0,maxmonth,i,x;
for(x=1980;xyear2;x++)
{ if((p+x-1979)->specialmonth==0)maxmonth=12;
else maxmonth=13;
for(i=0;i
if((p+x-1979)->month1[i]==0)n+=29;
else n+=30;
}
if((p+op->year2-1979)->specialmonth!=0)
if((p+op->year2-1979)->specialmonthmonth2)op->month2++;
for(i=1;imonth2;i++)
{
if((p+op->year2-1979)->month1[i-1]==0)n+=29;
else n+=30;}
n+=(op->day2-1);
n+=46;
return n;
}
void work_out2(struct day *re,struct data *p,int n)
{
int n1=0,maxday,maxmonth,month,day,judge=0;
re->year2=1979;re->month2=11;re->day2=14;
while(1)
{
if(judge==1)break;
if(p->specialmonth==0)maxmonth=12;
else maxmonth=13;
if(p->year1==1979)month=12;
else month=1;
for(;month<=maxmonth;month++)
{
if(p->month1[month-1]==0)maxday=29;
else maxday=30;
if((p->year1==1979)&&(maxday==30))day=14;
else day=1;
for(;day<=maxday;day++)
{
if(n1==n){if(maxmonth==13&&month>p->specialmonth)month-=1;
re->year2=p->year1;re->month2=month;re->day2=day;judge=1;break;}
else n1+=1;
}
if(judge==1)break;}
p++;
}
}
void work_out1(struct day *re,int n,int *p)
{
int year=1980,n1=0,month,day,maxday,judge=0;
re->year2=1980;re->month2=1;re->day2=1;
while(1)
{
*(p+1)=28;
if(judge==1)break;
if((year%4==0&&year%100!=0)||(year%100==0&&year%400==0))*(p+1)=29;
for(month=1;month<=12;month++)
{
maxday=*(p+month-1);
for(day=1;day<=maxday;day++)
{
if(n1==n){re->year2=year;re->month2=month;re->day2=day;judge=1;break;}
else n1++;
}
if(judge==1)break;}
year++;
}
}
main()
{
int n,c;
int sun[12]={31,28,31,30,31,30,31,31,30,31,30,31};
int *p1=sun;
struct day ob,re; struct data *p2;
struct data year[37]={
{1979,6, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0 },
{1980,0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 0, 1, 1, 0 },
{1981,0, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 1, 0 },
{1982,4, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 1, 1 },
{1983,0, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 0 },
{1984,10,1, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1 },
{1985,0, 0, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0 },
{1986,0, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 0, 0 },
{1987,6, 1, 0, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 0 },
{1988,0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 1, 0, 0 },
{1989,0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 1, 1, 0 },
{1990,5, 0, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 1 },
{1991,0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 0 },
{1992,0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 0 },
{1993,3, 0, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0 },