> 知识 >

c语言编程题 已知2012年1月1日是星期日,现在输入其后的任意一个日期(年份不超过9999),计算该日是星期几.
要求在主函数中调用自定义函数days进行求解,计算结果传回主函数
输出.函数的实参和形参均要求使用结构体变量.

人气:234 ℃ 时间:2025-06-08 19:39:06
解答

#include"stdio.h"
typedef struct {
int year;
int month;
int day;
}Date;
bool IsLeapYear(int year)
{
if(year%4==0)
{
if(year%100==0)
{
if(year%400==0)
return true;
return false;
}
else
return true;
}
else
return false;
}
int days(Date date)
{
int weekday=7;
for(int year=2012;yea

推荐
猜你喜欢
© 2024 79432.Com All Rights Reserved.
电脑版|手机版