intdayOfWeek(intyear,intmonth,intday){//蔡勒公式if(month==1||month==2)//判断month是否为1或2year--,month+=12;intc=year/100;inty=year-c*100;intweek=y+y/4+c/4-2*c+26*(month+1)/10+day-1;while(week<0)week+=7;returnweek=week%7-1;} 获取当前日期的年月日 首先使用了C语言的标...
#pragma once #ifndef CALENDER_H_ #define CALENDER_H_ // 宏定义布尔类型 #define BOOL int #define TRUE 1 #define FALSE 0 // 计算某天是星期几 int countWhichDayOfWeek(int year, int month, int day) { int y = year % 100; // y是年份后两位 int c = year / 100; // c是年份前两位(...
myDATELunar(myDATEdate);//输入阳历日期,返回阴历日期 char*dayOfWeek(myDATEdate);//输入阳历日期,返回星期几 char*getLunarString(myDATEdate);//输入阴历日期,得到表示农历的字串 UINTsolarDays(UINTy,UINTm);//传回国历y年某m 1月的天数 private: char m_slunar[100];//用于存储农历信息 staticDWORD l...
private static bool IsWeekDay(DateTime timeOfToll) => timeOfToll.DayOfWeek switch { DayOfWeek.Monday => true, DayOfWeek.Tuesday => true, DayOfWeek.Wednesday => true, DayOfWeek.Thursday => true, DayOfWeek.Friday => true, DayOfWeek.Saturday => false, DayO...
//主程序#include<iostream>using namespacestd;intdays;intget_dayofweek();intget_year();intget_month(int);intmain(){intyear,month,dayofweek;intleap_year;charweek[7][10] = {"Saturday","Sunday","Monday","Tuesday","Wednesday","Thursday","Friday"};while((cin>>days) && days!=-1) ...
switch (dayOfWeek) { case 1: printf("星期一\n"); break; case 2: printf("星期二\n"); break; case 3: printf("星期三\n"); break; default: printf("非法的星期\n"); break; } ``` 5. while语句:while语句用于当给定条件为真时重复执行一段代码块。例如: ```c while (x > 0) { pri...
day);cout << "这一天是星期" << dayOfWeek << endl;} else { cout << "请提供2000年之后的日期" << endl;} return 0;} 这个程序首先获取用户输入的年、月、日,然后使用Zeller公式来计算星期几,最后根据计算结果输出星期几的名称。请注意,这个程序中的月份是1到12,而日期是1到31 ...
printf("%d-%02d-%02d %s\n", i, j+1, days+1, week[dayofweek]); } return 0; } 72-2 特殊日历计算 问题描述 有一种特殊的日历法,它的一天和我们现在用的日历法的一天是一样长的。它每天有10个小时,每个小时有100分钟,每分钟有100秒。10天算一周,10周算一个月,10个月算一年。现在要你编写一...
用户输入是否是工作日(y/n)与星期几。如果是工作日,则星期一输出“中午吃牛肉面”,星期二输出“中午吃卤肉面”。 char isWorkingDay = 0; int dayOfWeek; printf("请输入是否是工作日(y/n), 与星期几:"); scanf("%c %d", &isWorkingDay, &dayOfWeek); ...
{ int dayOfWeek; int YY = year % 100; int century = year / 100; printf("\nDate: %d/%d/%d \n", date, month, year); dayOfWeek = 1.25 * YY + fm(date, month, year) + date - 2 * (century % 4); //remainder on division by 7 dayOfWeek = dayOfWeek % 7; switch (dayOfWeek)...