📄 week.c
字号:
#include<iostream.h>
#include<string.h>
#include<iomanip.h>
typedef unsigned char int8u;
typedef unsigned int int16u;
typedef struct
{
unsigned int Yea;
unsigned char Mon;
unsigned char Day;
}TDate;
unsigned char MonDayCount[12]={31,28,31,30,31,30,31,31,30,31,30,31};
unsigned char JudgeWeekDay(TDate curdate)
{
unsigned int x,s,c;
unsigned char i;
x = curdate.Yea;
c = 0;
for(i=1;i<curdate.Mon;i++)
{
c += MonDayCount[i-1];
}
c = c + curdate.Day;
if((x%4==0)&&(x%100 != 0)||(x%400 == 0))
{
c++;
}
x = x-1;
s = x + x/4 - x/100 + x/400 + c;
i = s%7;
return i;
}
void main(void)
{
TDate CurrentDate;
cout << "this is a test the weekday function:\n";
cout << "Please input the year which you want to test:";
cin >> CurrentDate.Yea;
cout << "Month is :";
cin >> CurrentDate.Mon;
cout << "Date is :";
cin >> CurrentDate.Day;
cout >>"the date is : ">>JudgeWeekDay(CurrentDate);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -