u011862238 于 2014.05.28 10:43 提问

#include
#include

/* run this program using the console pauser or add your own getch, system("pause") or input loop */
int leap(int a);

int number(int year,int m ,int d);

int main(int argc, char *argv[]) {
int year, month,day,n;
printf("请输入年月日\n");
//sacanf("%d,%d,%d",&year,&month,&day);
sacanf("%d,%d,%d",&year,&month,&day);
n=number(year,month,day);
if((n%5)0)
printf("%d%d%d 打渔\n",year,month,day);
else
printf("%d%d%d 嗮网\n",year,month,day);
return 0;
}
int leap(int a){
if(a%4==0 && a%100!=0 || a%400==0)
return 1;
else
return 0;
}

int number(int year,int m ,int d){
int sum=0,i,j;
int a[12]={31,28,31,30,31,30,31,31,30,31,30,31};
int b[12]={31,29,31,30,31,30,31,31,30,31,30,31};

``````if(leap(year==1))
for(i=0;i<m-1;i++)
sum+=b[i];
else
for(i=0;i<m-1;i++)
sum+=a[i];

for(j=2011;j<year;j++)
if(leap(j)==1)
sum+=366;
else
sum+=365;
sum+=d;
return sum;
}
``````

1个回答

lym753024200   2014.05.28 11:15

lym753024200 输入函数是scanf不是sacanf吧？我也只见过scanf_s
3 年多之前 回复
u011862238 还是谢谢你 是输入函数的 不信百度就知道了
3 年多之前 回复
u011862238 输入函数啊。。。
3 年多之前 回复