#include<stdio.h>
#include <stdbool.h>
struct date
{
int moth;
int day;
int year;
};
int main()
{
bool judgeLeap(int year);
int judgeMo(int year,int moth);
int judgeDay(int year, int moth, int day);
struct date dateV;
printf("请输入年-月-日:n");
scanf("%d-%d-%d",&dateV.year,&dateV.moth,&dateV.day);
printf("%d月%d日是%d年的第%d天n", dateV.moth, dateV.day, dateV.year,
judgeDay(dateV.year, dateV.moth, dateV.day));
return 0;
}
bool judgeLeap(int year)
{
if ((year % 400 == 0) || (year % 100 != 0 && year % 4 == 0)) {
return true;
}
else {
return false;
}
}
int judgeMo(int year, int moth)
{
switch (moth)
{
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12:
return(31);break;
case 2:
if (judgeLeap(year)) {
return(29);break;
}
else {
结构体:计算输入日期是该年的第几天_定义一个日期的结构体变量,计算改日在本年中是第几天...
最新推荐文章于 2023-06-01 11:54:23 发布