大概是我上一个简单日历加了些东西;详情如下;c语言简单日历,万年历;_flowkite_8097的博客-CSDN博客y
完整代码如下:
#define _CRT_SECURE_NO_WARNINGS//Vs特性防止scanf报错
#include
int main() {
int sbsrn(int year);//判断是不是闰年的函数
int sc(int n, int d1,int i1);//输出每个月的日历的函数
int yfts(int n, int year,int a[]);//判断月份天数的函数
int gyts(int year,int a[]);//计算公元一年一月一号到输入年份的总天数的函数
int year=1;
int b[12] = { 1,2,3,4,5,6,7,8,9,10,11,12 };
int a[12] = { 0 };
int n,i,v=-1;
for (; v!= 0;) {//输入0退出循环
printf("|输入1查全年日历\n|输入2精准查找单个或几个月份的日历\n|输入0退出\n");
scanf("%d",&v);
system("cls");
switch (v) {
case 1://输入1查全年日历
printf("请输入年份\n");
scanf_s("%d", &year);
printf("%d年的日历\n", year);
gyts(year, b);
break;
case 2://输入2精准查找单个或几个月份的日历
system("cls");
printf("请输入年份\n");
scanf_s("%d", &year);
printf("%d年的日历\n", year);
printf("输入要查找的月份的个数\n");
scanf("%d", &n);
printf("输入要查找的月份数\n");
for (i = 0; i < n; i++) {
scanf("%d",&a[i]);
}
gyts(year, a);
break;
case 0:break;
default:system("cls"); break;
}
}
return 0;
}
int sbsrn(int year) {//判断是不是闰年的函数
if (year % 4 == 0 && year % 100 != 0 || year % 400 == 0) {
return 1;
}
else return 0;
}
int sc(int n,int d1,int i1) {//输出每个月的日历的函数
int t,i;
printf("\t\t\t%d月份\n\n", i1);
printf("一\t二\t三\t四\t五\t六\t日\n\n");
t = n % 7;
for (i = 0; i < t; i++) {//输出每月一号前的空格
printf("\t");
}
for (i = 1; i |