为什么不对 !!
#include "stdio.h"
#define cdate 13
int fun_year(int y)
{
if (y % 4 == 0 && y % 100 != 0 || y % 400 == 0)
return 1;
else
return 0;
}
int fun_day1(int year,int month, int day)
{
int a[12] = { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
int b[12] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
int s=0;
if (fun_year(year))
{
while (month - 1 > 0)
{
s += a[month - 2];
month--;
}
}
else
{
while (month - 1 > 0)
{
s += b[month - 2];
month--;
}
}
return s + day;
}
int main()
{
int y=0,s=1,i,j,a0,day1[12],day2[60],count=0;
int f;
while (y < 1998)
scanf("%d", &y);
if (y == 1998)
{
a0 = 2;
}
else
{
for (i = 1998; i < y - 1; i++)
{
s = fun_year(i) + 365;
}
a0 = 7 -( s-1 ) % 7 ;
}
f = fun_year(y);
for (i = 0; i < 12; i++)
{
day1[i] = fun_day1(y, i + 1, cdate);
}
j = 0;
for (i = 0; i < 365 + f; i+=7)
{
day2[j++] = a0 + i;
}
int k = j;
for(i=0;i<12;i++)
for (j = 0; j < k; j++)
{
if (day1[i] == day2[j])
{
count++;
break;
}
}
printf("%d", count);
system("pause");
return 0;
}
0.0分
0 人评分
C二级辅导-计负均正 (C语言代码)浏览:652 |
C语言程序设计教程(第三版)课后习题11.5 (C语言代码)浏览:1019 |
C语言程序设计教程(第三版)课后习题9.4 (Java代码)浏览:1446 |
字符串问题 (C语言代码)浏览:1635 |
Pascal三角 (C语言代码)格式错误浏览:551 |
C语言程序设计教程(第三版)课后习题6.9 (C语言代码)浏览:1052 |
printf基础练习2 (有点不明白)浏览:887 |
【明明的随机数】 (C语言代码)浏览:845 |
【矩阵】 (C++代码)浏览:999 |
1113题解浏览:823 |