#include<stdio.h>
int count(int a[12],int b[12],int year,int mounth,int day)//定義一個count函式
{
int i,sum=0;
if(year%4==0&&year%100!=0||year%400==0)//判斷是否是閏年,若是則
for(i=0;i<mounth;i++)
sum+=a[i];
}
else
sum+=b[i];
sum+=day;
return(sum);
void main()
int year,mounth,day,m;
int
a[12]={31,29,31,30,31,30,31,31,30,31,30,31},
b[12]={31,28,31,30,31,30,31,31,30,31,30,31};
//a陣列是定義的閏年每月份的天數,b陣列是定義的非閏年每月份的天數
printf("請輸入年year,月mounth,日day\n");
scanf("%d,%d,%d",&year,&mounth,&day);
m=count(a,b,year,mounth,day);
printf("%d\n",m);
#include<stdio.h>
int count(int a[12],int b[12],int year,int mounth,int day)//定義一個count函式
{
int i,sum=0;
if(year%4==0&&year%100!=0||year%400==0)//判斷是否是閏年,若是則
for(i=0;i<mounth;i++)
{
sum+=a[i];
}
else
for(i=0;i<mounth;i++)
{
sum+=b[i];
}
sum+=day;
return(sum);
}
void main()
{
int year,mounth,day,m;
int
a[12]={31,29,31,30,31,30,31,31,30,31,30,31},
b[12]={31,28,31,30,31,30,31,31,30,31,30,31};
//a陣列是定義的閏年每月份的天數,b陣列是定義的非閏年每月份的天數
printf("請輸入年year,月mounth,日day\n");
scanf("%d,%d,%d",&year,&mounth,&day);
m=count(a,b,year,mounth,day);
printf("%d\n",m);
}