int normalMonth[12] = {31,28,31,30,31,30,31,31,30,31,30,31}
int leapMonth[12] = {31,29,31,30,31,30,31,31,30,31,30,31}
int getYear(void)
{
int n
printf("please input year:")
scanf("%d",&n)
return n
}
int isLeap(int n)
{
if((n%4==0&&n%100!=0)||n%400==0)
{
return 366
}
else
{
return 365
}
}
int weekDays(int year)
{
int i,sum = 0
for(i = 2008i<yeari++)
{
sum += isLeap(i)
}
if(sum == 0)
{
sum = 0
}
else
{
sum = sum%7
}
switch (sum)
{
case 0:
return 3
break
case 1:
return 4
break
case 2:
return 5
break
case 3:
return 6
break
case 4:
return 7
break
case 5:
return 1
break
case 6:
return 2
break
default:
return -10000
}
}
void darkFriday(int weekday,int year)
{
int week = weekday,i,j,sum = 0
if(366==isLeap(year))
{
for(i=0i<12i++)
{
for(j=1j<=leapMonth[i]j++)
{
week++
if(week == 8)
{
week = 1
}
if(week == 5&&j == 13)
{
sum ++
}
}
}
}
else
{
for(i=0i<12i++)
{
for(j=1j<=normalMonth[i]j++)
{
week++
if(week == 8)
{
week = 1
}
if(week == 5&&j == 13)
{
sum ++
}
}
}
}
printf("%d\n",sum)
}
int main(void)
{
int year,weekday
year = getYear()
weekday = weekDays(year)
darkFriday(weekday,year)
return 0
}
main(){
int i//红球
int j//白球
int k//黑球
int count=0
for(i=0i<=3i++)
for(j=1j<=5j++)//必有白球
for(k=0k<=6k++)
if(i+j+k==8)
{
printf("%d\t%d\t%d",i,j,k)
count++
}
printf("%d",count)
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)