problemscpp
A collection of my answers to algorithm problems in c++.
函数
pat::b::b1014 命名空间参考

1014 福尔摩斯的约会 更多...

函数

int main (istream &cin, ostream &cout)
 
 TEST (b1014, case1)
 

详细描述

1014 福尔摩斯的约会

函数说明

◆ main()

int pat::b::b1014::main ( istream &  cin,
ostream &  cout 
)

在文件 pat.cpp452 行定义.

452 {
453 string str1;
454 string str2;
455 cin >> str1 >> str2;
456 string day;
457 const vector<string> days = {"MON", "TUE", "WED", "THU", "FRI", "SAT", "SUN"};
458 int hh;
459 int mm;
460 for(int i = 0; i < str1.length() && i < str2.length(); i++) {
461 if(str1[i] == str2[i]) {
462 if(day.empty()) {
463 if(isupper(str1[i]) != 0) {
464 day = days[str1[i] - 'A'];
465 }
466 } else if(isdigit(str1[i]) != 0 || 'A' <= str1[i] && str1[i] <= 'N') {
467 if(isdigit(str1[i]) != 0) {
468 hh = str1[i] - '0';
469 } else {
470 hh = 10 + str1[i] - 'A';
471 }
472 break;
473 }
474 }
475 }
476 cin >> str1 >> str2;
477 for(int i = 0; i < str1.length() && i < str2.length(); i++) {
478 if(str1[i] == str2[i] && isalpha(str1[i]) != 0) {
479 mm = i;
480 break;
481 }
482 }
483 cout << day << ' ' << setw(2) << right << setfill('0') << hh << ':' << setw(2) << right << setfill('0') << mm;
484 return 0;
485 }

引用了 acwing::acwing1929::right.

被这些函数引用 TEST().

◆ TEST()

pat::b::b1014::TEST ( b1014  ,
case1   
)

在文件 pat_test.cpp193 行定义.

193 {
194 istringstream in("3485djDkxh4hhGE \n"
195 "2984akDfkkkkggEdsb \n"
196 "s&hgsfdk \n"
197 "d&Hyscvnm");
198 auto out = ostringstream();
199 main(in, out);
200 const auto ans = out.str();
201 ASSERT_EQ("THU 14:04", ans);
202 }
int main(int argc, char **argv)
Definition: main.cpp:5

引用了 main().