由于标题清除了它,我想计算给定年份范围内给定日期的总数,范围介于1600-2500之间c语言。我已经写了一些代码,但在闰年的日子里被困住了。请帮帮我。用C语言计算给定日期(即星期日或星期一或星期几等)的总数
#include
#include
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);
}
2013-07-01
Abhigyan
+0
你的'calculateNoOfDays()'看起来像什么? –
+0
另外,请注意,你应该从'main'返回'0'来表示成功。 –
+1
要继续使用@Lstor关于'main'的“唠叨”,对于不带参数的函数,您也应该始终使用“void”参数。否则,在C中,函数被指定为获取未知数量的未知参数。 –