永发信息网

这个程序怎么改

答案:1  悬赏:60  手机版
解决时间 2021-05-10 11:18
  • 提问者网友:愿为果
  • 2021-05-09 14:11

#include <stdio.h>
#include <stdlib.h>

#define baseYear 2000

void Week(int num, char *pWeek)
{
char Week[][12] = {"Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"};

*pWeek = Week[num%7 - 1][12];
}

void Year(int *pNum, int *pYear)
{
int i;

for(i=1;*pNum<365;i++)
{
if((i%4==0&&i%100!=0)||(i%400==0))
{
*pNum=*pNum-366;
}
else
{
*pNum=*pNum-365;
}
}
*pYear=baseYear + i;
}

void Month(int num,int year,int *pMonth,int *pDay)
{
int monthDay[2][13] = {{0,31,28,31,30,31,30,31,31,30,31,30,31},{0,31,29,31,30,31,30,31,31,30,31,30,31}};
int i;
int flag;

flag = (i%4==0&&i%100!=0)||(i%400==0);
for (i=1;num<monthDay[flag][i];i++)
{
num = num-monthDay[flag][i];
}
*pMonth = i;
*pDay = num;
}

int main()
{
int num;
int year,month,day;
int week[12];

printf("Please enter the number:");
scanf("%d",&num);

Week(num,week);
Year(&num,&year);
Month(num,year,&month,&day);

printf("\n%d-%d-%d ",year,month,day,week);
return 0;
}
万年历的程序 各位应该知道吧 帮我找找bug吧 多谢

最佳答案
  • 五星知识达人网友:渡鹤影
  • 2021-05-09 15:29

本人还没搞懂,万年历的算法的,那月多少天,每年要润个月,也还没搞明白怎么算


帮补了你了


我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯