Epsilon LTT 2020-12-30 10:00 采纳率: 77.8%

# 这个万年历程序该怎么修改呢？

#include <stdio.h>
int Year,Month,Day,week_day;
double Days_interval;//不包括那一月的间隔天数
int main()
{
printf("请输入年月日：");
scanf("%d%d%d",&Year,&Month,&Day);
double Days_Interval();//总天数间隔
int SX();//生肖;
int Month_days();//判断那个月有多少天
int Week_day();//每月1号是星期几
void print();
return 0;
}

double Days_Interval()//计算总天数间隔
{
int year=1900,month=1;
double Days_Interval=0;
for(year=1900;year<Year;year++)
{
if ((Year % 4 == 0 && Year %100 != 0) || (Year % 400 == 0))
{
Days_Interval+=366;
}
else
{
Days_Interval+=365;
}
}
for(month=1;month<Month;month++)
{
switch(month)
{
case 1:Days_Interval+=31;break;
case 2:if((Year % 4 == 0 && Year %100 != 0) || (Year % 400 == 0))
{
Days_Interval+=29;
}
else
{
Days_Interval+=28;
}break;
case 3:Days_Interval+=31;break;
case 4:Days_Interval+=30;break;
case 5:Days_Interval+=31;break;
case 6:Days_Interval+=30;break;
case 7:Days_Interval+=31;break;
case 8:Days_Interval+=31;break;
case 9:Days_Interval+=30;break;
case 10:Days_Interval+=31;break;
case 11:Days_Interval+=30;break;
case 12:Days_Interval+=31;break;
}
Days_interval=Days_Interval;
Days_Interval+=Day;
}
int Month_days()//判断这个月有多少天
{
if(Month==2)
{
if((Year % 4 == 0 && Year %100 != 0) || (Year % 400 == 0))
Month_days=29;
else Month_days=28;
}
else if(Month==1||Month==3||Month==5||Month==7||Month==8||Month==10||Month==12)
Month_days=31;
else Month_days=30;
return 0;
}

int Week_day()//计算每月1号是星期几
{
Days_interval+=1;
week_day=Days_interval%7;
return (week_day);
}
int SX()//判断生肖
{
int x;
x=(Year-1900)%12;
switch(x)
{
case 0:printf("%d年是鼠年",Year);break;
case 1:printf("%d年是牛年",Year);break;
case 2:printf("%d年是虎年",Year);break;
case 3:printf("%d年是兔年",Year);break;
case 4:printf("%d年是龙年",Year);break;
case 5:printf("%d年是蛇年",Year);break;
case 6:printf("%d年是马年",Year);break;
case 7:printf("%d年是羊年",Year);break;
case 8:printf("%d年是猴年",Year);break;
case 9:printf("%d年是鸡年",Year);break;
case 10:printf("%d年是狗年",Year);break;
case 11:printf("%d年是猪年",Year);break;
}
return 0;
}
void print()
{
int i=1;
print("一    二    三    四    五    六    日    \n");
for(i=1;i<week_day;i++)
printf("\t");
for(i=1;i<Month_days;i++)
{
printf("%4d",i);
week_day++;
if (week_day%7==0&&i<=Month_days)
printf("\n");
}
}

• 写回答

#### 8条回答默认 最新

• bosaidongmomo 2020-12-30 10:20
关注
``````#include <stdio.h>
int Year, Month, Day, week_day;
double Days_interval;//不包括那一月的间隔天数
int m_month_days;
int main()
{
printf("请输入年月日：");
scanf("%d%d%d", &Year, &Month, &Day);
double Days_Interval();//总天数间隔
int SX();//生肖;
int Month_days();//判断那个月有多少天
int Week_day();//每月1号是星期几
void print();
Days_Interval();
SX();
Month_days();
Week_day();
print();
return 0;
}

double Days_Interval()//计算总天数间隔
{
int year = 1900, month = 1;
double Days_Interval = 0;
for (year = 1900; year < Year; year++)
{
if ((Year % 4 == 0 && Year % 100 != 0) || (Year % 400 == 0))
{
Days_Interval += 366;
}
else
{
Days_Interval += 365;
}
}
for (month = 1; month < Month; month++)
{
switch (month)
{
case 1:Days_Interval += 31; break;
case 2:if ((Year % 4 == 0 && Year % 100 != 0) || (Year % 400 == 0))
{
Days_Interval += 29;
}
else
{
Days_Interval += 28;
}break;
case 3:Days_Interval += 31; break;
case 4:Days_Interval += 30; break;
case 5:Days_Interval += 31; break;
case 6:Days_Interval += 30; break;
case 7:Days_Interval += 31; break;
case 8:Days_Interval += 31; break;
case 9:Days_Interval += 30; break;
case 10:Days_Interval += 31; break;
case 11:Days_Interval += 30; break;
case 12:Days_Interval += 31; break;
}
Days_interval = Days_Interval;
Days_Interval += Day;
}
return Days_Interval;
}
int Month_days()//判断这个月有多少天
{
if (Month == 2)
{
if ((Year % 4 == 0 && Year % 100 != 0) || (Year % 400 == 0))
m_month_days = 29;
else m_month_days = 28;
}
else if (Month == 1 || Month == 3 || Month == 5 || Month == 7 || Month == 8 || Month == 10 || Month == 12)
m_month_days = 31;
else m_month_days = 30;
return 0;
}

int Week_day()//计算每月1号是星期几
{
Days_interval += 1;
week_day = (int)Days_interval % 7;
return (week_day);
}
int SX()//判断生肖
{
int x;
x = (Year - 1900) % 12;
switch (x)
{
case 0:printf("%d年是鼠年", Year); break;
case 1:printf("%d年是牛年", Year); break;
case 2:printf("%d年是虎年", Year); break;
case 3:printf("%d年是兔年", Year); break;
case 4:printf("%d年是龙年", Year); break;
case 5:printf("%d年是蛇年", Year); break;
case 6:printf("%d年是马年", Year); break;
case 7:printf("%d年是羊年", Year); break;
case 8:printf("%d年是猴年", Year); break;
case 9:printf("%d年是鸡年", Year); break;
case 10:printf("%d年是狗年", Year); break;
case 11:printf("%d年是猪年", Year); break;
}
return 0;
}
void print()
{
int i = 1;
printf("一    二    三    四    五    六    日    \n");
for (i = 1; i<week_day; i++)
printf("\t");
for (i = 1; i<m_month_days; i++)
{
printf("%4d", i);
week_day++;
if (week_day % 7 == 0 && i <= m_month_days)
printf("\n");
}
}``````
本回答被题主选为最佳回答 , 对您是否有帮助呢?
评论

#### 悬赏问题

• ¥15 聚类分析或者python进行数据分析
• ¥15 逻辑谓词和消解原理的运用
• ¥15 三菱伺服电机按启动按钮有使能但不动作
• ¥15 js，页面2返回页面1时定位进入的设备
• ¥50 导入文件到网吧的电脑并且在重启之后不会被恢复
• ¥15 （希望可以解决问题）ma和mb文件无法正常打开，打开后是空白，但是有正常内存占用，但可以在打开Maya应用程序后打开场景ma和mb格式。
• ¥20 ML307A在使用AT命令连接EMQX平台的MQTT时被拒绝
• ¥20 腾讯企业邮箱邮件可以恢复么
• ¥15 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗？
• ¥15 错误 LNK2001 无法解析的外部符号