#include<stdio.h>
int sum_day(int(*)[13],int,int,int);
void main()
{
int year,month,day,days;
int day_tab[2][13]={{0,31,28,31,30,31,30,31,31,30,31,30,31},
{0,31,29,31,30,31,30,31,31,30,31,30,31}};/*记录每个月的天数*/
printf("请输入年、月、日(形如:1980 4 9):\n");
scanf("%d%d%d",&year,&month,&day);
days=sum_day(day_tab,year,month,day);
printf("这是该年的第%d天\n",days);
}
int sum_day(int (*p)[13],int y,int m,int d) /*指针变量p指向二维数组的一行*/
{
int i,leap=0;
leap=y%4==0&&y%100!=0||y%400==0; /*如果为闰年,leap为1*/
for(i=1;i<m;i++)
d+=*(*(p+leap)+i);
return d;
}