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

1027 Colors in Mars 更多...

函数

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

详细描述

1027 Colors in Mars

函数说明

◆ main()

int pat::a::a1027::main ( istream &  cin,
ostream &  cout 
)

在文件 pat.cpp4995 行定义.

4995 {
4996 const char num[13] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C'};
4997 unsigned input[3];
4998 cin >> input[0] >> input[1] >> input[2];
4999 stack<char> stk;
5000 ostringstream oss;
5001 oss << '#';
5002 for(int i = 0; i < 3; i++) {
5003 unsigned color = input[i];
5004 while(color != 0) {
5005 stk.push(num[color % 13]);
5006 color /= 13;
5007 }
5008 while(stk.size() < 2) {
5009 stk.push('0');
5010 }
5011 while(!stk.empty()) {
5012 oss << stk.top();
5013 stk.pop();
5014 }
5015 }
5016 cout << oss.str();
5017 return 0;
5018 }

被这些函数引用 TEST().

◆ TEST()

pat::a::a1027::TEST ( a1027  ,
case1   
)

在文件 pat_test.cpp2250 行定义.

2250 {
2251 istringstream in("15 43 71");
2252 auto out = ostringstream();
2253 main(in, out);
2254 ASSERT_EQ("#123456", out.str());
2255 }
int main(int argc, char **argv)
Definition: main.cpp:5

引用了 main().