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

#include <leetcode.h>

静态 Public 成员函数

static int convertTime (string current, string correct)
 

详细描述

在文件 leetcode.h2037 行定义.

成员函数说明

◆ convertTime()

int leetcode::minimum_number_of_operations_to_convert_time::Solution::convertTime ( string  current,
string  correct 
)
static

在文件 leetcode.cpp5530 行定义.

5530 {
5531 const int current_h = (current[0] - '0') * 10 + (current[1] - '0');
5532 const int current_m = (current[3] - '0') * 10 + (current[4] - '0');
5533 const int correct_h = (correct[0] - '0') * 10 + (correct[1] - '0');
5534 const int correct_m = (correct[3] - '0') * 10 + (correct[4] - '0');
5535 int diff = correct_h * 60 + correct_m - (current_h * 60 + current_m);
5536 if(diff < 0) {
5537 diff += 24 * 60;
5538 }
5539 int ans = 0;
5540 ans += diff / 60;
5541 diff %= 60;
5542 ans += diff / 15;
5543 diff %= 15;
5544 ans += diff / 5;
5545 diff %= 5;
5546 ans += diff;
5547 return ans;
5548 }

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


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