problemscpp
A collection of my answers to algorithm problems in c++.
静态 Public 成员函数 | 所有成员列表
leetcode::day_of_the_week::Solution类 参考

#include <leetcode.h>

静态 Public 成员函数

static string dayOfTheWeek (int day, int month, int year)
 

详细描述

在文件 leetcode.h215 行定义.

成员函数说明

◆ dayOfTheWeek()

string leetcode::day_of_the_week::Solution::dayOfTheWeek ( int  day,
int  month,
int  year 
)
static

在文件 leetcode.cpp475 行定义.

475 {
476 const string output[] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};
477 const int dayofmonths[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
478 int count = 5;
479 count += (year - 1971) * 365;
480 count += (year - 1) / 4 - 1970 / 4;
481 for(int m = 0; m < month - 1; m++) {
482 count += dayofmonths[m];
483 }
484 if(month > 2 && year % 4 == 0 && year % 100 != 0) {
485 count++;
486 }
487 count += day - 1;
488 count %= 7;
489 return output[count];
490 }

被这些函数引用 leetcode::day_of_the_week::TEST().


该类的文档由以下文件生成: