unit1.~cpp

来自「萬年曆查詢星期:輸入年月日就可以查詢當天是星期幾」· ~CPP 代码 · 共 63 行

~CPP
63
字号
//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma link "ccalendr"
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
        : TForm(Owner)
{
        LeapYear = 0;
}
//---------------------------------------------------------------------------
static int CountOfLeapYear(int year)
{
        int countyear1 = year%400;
        int countyear2 = countyear1%100;
        int countyear3 = countyear2%4;
        int count1 = year/400;
        int count2 = countyear1/100;
        int count3 = countyear2/4;
        int totalcount = count1*97 + count2*24 + count3;
        return totalcount;
}
//---------------------------------------------------------------------------
static int CountOfMonth(int month)
{
        int MonthInaYear[]={31,28,31,30,31,30,31,31,30,31,30,31};
        int result = 0;
        for(int i=0;i<month;++i)
        {
                result += MonthInaYear[i];
        }
        return result;
}
//---------------------------------------------------------------------------
static int CountDaysFrom(int year,int month,int day)
{
        int leapYear = CountOfLeapYear(year-1);

        int md = CountOfMonth(month-1);
        if(IsLeapYear(year) && month>2)
        {
                ++md;
        }
		return ((year-1)*365 + leapYear + md + day);

}

//---------------------------------------------------------------------------
void __fastcall TForm1::btnCloseClick(TObject *Sender)
{
        Close();
}
//---------------------------------------------------------------------------
void TForm1::Determine()
{
		String Week[] = {"ら","8","

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?