提供一个子程序供参考
void kao(int year,int month,int day)
{
int xuanzhe[2][12]={{31,28,31,30,31,30,31,31,30,31,30,31},{31,28,31,30,31,30,31,31,30,31,30,31}};
int k,l,leap=(year%4==0&&year%100!=0)||(year%400==0);
for(k=0;k<month;k++)
day=day+xuanzhe[leap][k];
for(k=1990;k<year;k++)
leap=(k%4==0&&k%100!=0)||(k%400==0);
for(l=0;l<12;l++)
day=day+xuanzhe[leap][l];
return day;
}
有兴趣的还可以将它优化一下。