正如标题所清除的那样,我想用 c 语言计算给定年份范围内 1600-2500 之间的给定日期的总数。我写了一些代码,但坚持计算闰年天数。请帮我。
#include<stdio.h>
#include<string.h>
int calculateNoOfDays(int year,int choice);
int isLeap(int year);
int main()
{
int choice,year;
int count;
char dayName[12];
do{
printf("Please Enter a year between 1601 and 2500\n");
scanf("%d",&year);
}
while(!(year>=1601 && year<=2500));
printf("Please select an option between 1 and 7: \nMonday: 1\nTuesday: 2\nWednesday: 3\nThursday: 4\nFriday: 5\nSaturday: 6\nSunday: 7\n");
scanf("%d",&choice);
switch((choice))
{
case 1:strcpy(dayName,"Monday");
break;
case 2:strcpy(dayName,"Tuesday");
break;
case 3:strcpy(dayName,"Wednesday");
break;
case 4:strcpy(dayName,"Thursday");
break;
case 5:strcpy(dayName,"Friday");
break;
case 6:strcpy(dayName,"Saturday");
break;
case 7:strcpy(dayName,"Sunday");
break;
}
count=calculateNoOfDays(year,choice);
printf("For the given year, the number of %ss in that year is: %d \n",dayName,count);
return (1);
}