大一CS新生 做到一题函数和数组的题 出了问题 但是一直找不到问题在哪 求好心人指点
#include<stdio.h>#define months 12
#include<assert.h>
void ReadDate(int x, int y, int z);
void CacuDate(int a, int b, int c, int days1[], int days2[], int x, int y, int z);
main()
{
int a, b, c, w;
int x, y, z;
int days1[months] = {31,28,31,30,31,30,31,31,30,31,30,31};
int days2[months] = {31,29,31,30,31,30,31,31,30,31,30,31};
a = 2016;
b = 11;
c = 12;
w = 6;
printf("%d年%d月%d日是星期%d\n", a, b, c, w);
ReadDate(x, y, z);
CacuDate(a, b, c, days1, days2, x, y, z);
}
void ReadDate(int x, int y, int z)
{
printf("Input year:x month:y day:z :\n");
scanf("%d%d%d", &x, &y, &z);
assert( y>=1 && y<=12 && z>=1 && z<= 31 );
}
void CacuDate(int a, int b, int c, int days1[], int days2[], int x, int y, int z)
{
int i, j, n, sum1, sum2, sum3, sum;
sum1 = c;
sum = 0;
sum3 = 0;
n = z;
if( x<a )
{
for( i=0; i<b-1; i++)
{
sum1 += days1[i];
}
if( x%4==0 && x%100==0 || x%400==0 )
{
for ( i=0; i<y-1; i++ )
{
n += days2[i];
}
sum2 = 366-n;
}
else
{
for( i=0; i<y-1; i++)
{
n += days1[i];
}
sum2 = 365-n;
}
for ( j=x; j<a-1; j++ )
{
if((j+1)%4==0 && (j+1)%100==0 || (j+1)%400==0 )
{
sum3 += 366;
}
else
{
sum3 += 365;
}
}
}
sum = sum1+sum2+sum3;
printf("%d\n",sum);
}
问题应该是处在函数CacuDate中了 麻烦好心人看一下.