|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?注册
x
万年历在ADS1.2不能通过编译???请高手帮我解答一下
是怎样改才可以通过编译。。。多谢了。。。。非常感谢!
我的程序如下:
#include "stdio.h"
#include "dos.h"
#define PGUP 0x4900
#define PGDW 0x5100
#define ESC 0x011b
struct date dm;
int Cyear,Cmonth,Cday,Cmonnum,Lmonnum;
int isleap(int year)
{
if(year%4==0&&year%100||year%400==0)
return 1 ;
else
return 0 ;
}
int getday(int year,int month,int day)
{
int flag,s,i ;
int a[13]={0,31,28,31,30,31,30,31,31,30,31,30,31} ;
int cont=0 ;
flag=isleap(year);
if(flag==1)
a[2]++;
for(i=1;i<month;i++)
{
cont=cont+a;
}
cont=cont+day ;
s=year+1+(year-1)/4+(year-1)/100+(year-1)/400+cont ;
return s%7 ;
}
void printspace(int n)
{
int i ;
for(i=0;i<n;i++)printf(" ");
}
void spacer()
{
}
void keyinfo()
{
}
int week()
{
int day;
day=getday(Cyear,Cmonth,Cday);
if(day==0)
printf("\n%d-%d-%d is Sunday!\n",Cyear,Cmonth,Cday);
if(day==1)
printf("\n%d-%d-%d is Monday!\n",Cyear,Cmonth,Cday);
if(day==2)
printf("\n%d-%d-%d is Tuesday!\n",Cyear,Cmonth,Cday);
if(day==3)
printf("\n%d-%d-%d is Wednesday!\n",Cyear,Cmonth,Cday);
if(day==4)
printf("\n%d-%d-%d is Thursday!\n",Cyear,Cmonth,Cday);
if(day==5)
printf("\n%d-%d-%d is Friday!\n",Cyear,Cmonth,Cday);
if(day==6)
printf("\n%d-%d-%d is Saturday!\n",Cyear,Cmonth,Cday);
}
void calendar(int year,int month,int day)
{
int i,j,d,m,flag,week;
int a[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
m=0,d=0,week=0;
Cmonnum=a[month];
Lmonnum=a[month-1];
week=d=getday(year,month,1);
flag=isleap(year);
if(flag==1)
{
a[2]++;
}
clrscr();
spacer();
switch(month)
{
case 1 :
printf(" %d 1 %d ",year);
break ;
case 2 :
printf(" %d 2",year);
break ;
case 3 :
printf(" %d 3",year);
break ;
case 4 :
printf(" %d 4",year);
break ;
case 5 :
printf(" %d 5",year);
break ;
case 6 :
printf(" %d 6",year);
break ;
case 7 :
printf(" %d 7",year);
break ;
case 8 :
printf(" %d 8 %d ",year,day);
break ;
case 9 :
printf(" %d 9",year);
break ;
case 10 :
printf(" %d 10",year);
break ;
case 11 :
printf(" %d 11",year);
break ;
case 12 :
printf(" %d 12",year);
break ;
}
printf("\n");
printf(" Sun Mon Tue Wed Thu Fri Sat");
printf("\n");
for(i=0;i<6;i++)
{
if(i==0)
{
printspace(d*4);
for(j=0;j<7-d;j++)
{
if(m==day-1)
{
printf(" [%d]",++m);
}
else if(m==day && week!=0)
{
printf("%3d",++m);
}
else
{
printf("%4d",++m);
}
week=(week<6)?week+1:0;
}
printf("\n");
}
else
{
for(j=0;j<7;j++)
{
if(m<a[month])
{
if(m==day-1)
{
if(m<0)
printf(" [%d]",++m);
else
printf(" [%d]",++m);
}
else if(m==day && week!=0)
{
printf("%3d",++m);
}
else
{
printf("%4d",++m);
}
}
week=(week<6)?week+1:0;
}
printf("\n");
if(m==a[month])break ;
}
}
}
void key()
{
int key ;
Cyear=dm.da_year,Cmonth=dm.da_mon,Cday=dm.da_day ;
calendar(Cyear,Cmonth,Cday);
while(1)
{
key=bioskey(0);
if(key==PGUP)
{
if(Cday!=1)
{
Cday--;
}
else if(Cday==1&&Cmonth==1)
{
Cyear--;
Cmonth=12 ;
Cday=31 ;
}
else
{
Cmonth--;
Cday=Lmonnum ;
}
}
if(key==PGDW)
{
if(Cmonnum!=Cday)
{
Cday++;
}
else if(Cmonnum==Cday&&Cmonth==12)
{
Cyear++;
Cmonth=1 ;
Cday=1 ;
}
else
{
Cmonth++;
Cday=1 ;
}
}
if(key==ESC)break ;
calendar(Cyear,Cmonth,Cday);
}
}
void main()
{
clrscr();
getdate(&dm);
key();
}
[ 本帖最后由 chyhao 于 2006-8-18 10:21 编辑 ] |
|