一个程序 在VC++6.0中运行 的问题
#include <stdio.h> #include <conio.h>
#include<afx.h>
void calendar(int,int);
int leapyear(int);
int week(int,int,int);
int monthday[12]={31,28,31,30,31,30,31,31,30,31,30,31};
struct date
{
int da_day;
int da_mon;
int da_year;
};
int leapyear(int year)
{
return ((year%4==0 && year%100!=0) || (year%4==0 && year%400==0));
}
int week(int y,int m,int d)
{
if((m==1)||(m==2))
{
m+=12;
y--;
}
return ((d+2*m+3*(m+1)/5+y+y/4-y/100+y/400)+1)%7;
}
int main()
{
struct date d;
CTime::GetCurrentTime(&d);
printf("Today is %d year %d month %d day\n",d.da_year,d.da_mon,d.da_day);
calendar(d.da_year,d.da_mon-1);
system("pause");
return 0;
}
void calendar(int year,int month)
{
int d,i,s,c;
char x;
while(month>11) {
month-=12;
year++;
}
while(month<0) {
year--;
month+=12;
}
if(leapyear(year)) monthday[1]=29;
printf("%d %d\n",year,month+1);
printf("S M T W T F S\n\n");
s=week(year,month+1,1);
for(i=0; i<3*s; i++ ) printf(" ");
c=s;
for(d=1;d<=monthday[month];d++)
{
if(c>6)
{
printf("\n");
c=0;
}
c++;
printf("%d",d);
printf("%s",(d<10)?" ":" ");
}
printf("\n");
printf("nextmonth :N lastmonth :P quit :any keys. Choose: ");
x=getch();
printf("%c\n",x);
if(x=='N' || x=='n')
{
calendar(year,month+1);
}
else if(x=='P' || x=='p')
{
calendar(year,month-1);
}
else
{
printf("Thank you !\n");
return;
}
}
这是万年历,要求与系统时间同步 这个程序在VC++6.0中运行的时候报错了 请个高手看看是怎么回事?
谢谢各位!