【平仓期货源码】【php生成guid 源码】【驱动过保护源码】c 工作日历源码_c日历代码
1.c语言万年历程序。作日编写程序打印任意给定的历源平仓期货源码年份的日历或者某年某月的月历或者查询某一天是星期几?
c语言万年历程序。编写程序打印任意给定的日历php生成guid 源码年份的日历或者某年某月的月历或者查询某一天是星期几?
以下是一个示例的 C 代码,实现了打印给定年份的代码驱动过保护源码日历、某年某月的作日安卓心率源码月历以及查询某一天是星期几的功能:
#include <stdio.h>// 判断某年是否为闰年int isLeapYear(int year) {
if ((year % 4 == 0 && year % != 0) || year % == 0) {
return 1;
}
return 0;}// 获取某年某月的天数int getMonthDays(int year, int month) {
int days;
switch (month) {
case 2:
days = isLeapYear(year) ? : ;
break;
case 4:
case 6:
case 9:
case :
days = ;
break;
default:
days = ;
break;
}
return days;}// 计算某年某月1号是星期几int getWeekday(int year, int month) {
int d, m, y;
d = 1;
m = month;
y = year - (m < 3);
return (y + y / 4 - y / + y / + " - m + 2 * d + 3 * (m + 1) / 5 + y") % 7;}// 打印某一年的日历void printYearCalendar(int year) {
printf("========== %d 年日历 ==========\n", year);
for (int month = 1; month <= ; month++) {
printf("\n");
printf("======== %d 月 =======\n", month);
printf(" Sun Mon Tue Wed Thu Fri Sat\n");
int days = getMonthDays(year, month);
int weekday = getWeekday(year, month);
int currentDay = 1;
for (int i = 0; i < weekday; i++) {
printf(" ");
}
while (currentDay <= days) {
printf(" %3d", currentDay);
if ((currentDay + weekday) % 7 == 0) {
printf("\n");
}
currentDay++;
}
printf("\n");
}}// 打印某年某月的月历void printMonthCalendar(int year, int month) {
printf("======= %d 年 %d 月月历 =======\n", year, month);
printf(" Sun Mon Tue Wed Thu Fri Sat\n");
int days = getMonthDays(year, month);
int weekday = getWeekday(year, month);
int currentDay = 1;
for (int i = 0; i < weekday; i++) {
printf(" ");
}
while (currentDay <= days) {
printf(" %3d", currentDay);
if ((currentDay + weekday) % 7 == 0) {
printf("\n");
}
currentDay++;
}
printf("\n");}// 查询某一天是星期几void queryWeekday(int year, int month, int day) {
int weekday = getWeekday(year, month);
printf("%d 年 %d 月 %d 日是星期%d\n", year, month, day, (weekday + day - 1) % 7);}int main() {
int option;
int year, month, day;
printf("1. 打印某一年的日历\n");
printf("2. 打印某年某月的月历\n");
printf("3. 查询某一天是星期几\n");
printf("请选择操作:");
scanf("%d", &option);
if (option == 1) {
printf("请输入要打印的年份:");
scanf("%d", &year);
printYearCalendar(year);
} else if (option == 2) {
printf("请输入要打印的年份和月份,用空格分隔:");
scanf("%d%d",历源在线录音网站源码 &year, &month);
printMonthCalendar(year, month);
} else if (option == 3) {
printf("请输入要查询的年份、月份和日期,日历用空格分隔:");
scanf("%d%d%d",代码 &year, &month, &day);
queryWeekday(year, month, day);
}
return 0;}