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

1005 Spell It Right 更多...

函数

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

详细描述

1005 Spell It Right

函数说明

◆ main()

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

在文件 pat.cpp4073 行定义.

4073 {
4074 unsigned long n = 0;
4075 string s;
4076 cin >> s;
4077 for(const char ch: s) {
4078 n += ch - '0';
4079 }
4080 auto oss = ostringstream();
4081 oss << n;
4082 s = oss.str();
4083 bool first = true;
4084 for(const char ch: s) {
4085 if(!first) {
4086 cout << ' ';
4087 }
4088 first = false;
4089 switch(ch) {
4090 case '0':
4091 cout << "zero";
4092 break;
4093 case '1':
4094 cout << "one";
4095 break;
4096 case '2':
4097 cout << "two";
4098 break;
4099 case '3':
4100 cout << "three";
4101 break;
4102 case '4':
4103 cout << "four";
4104 break;
4105 case '5':
4106 cout << "five";
4107 break;
4108 case '6':
4109 cout << "six";
4110 break;
4111 case '7':
4112 cout << "seven";
4113 break;
4114 case '8':
4115 cout << "eight";
4116 break;
4117 case '9':
4118 cout << "nine";
4119 break;
4120 default: return -1;
4121 }
4122 }
4123 return 0;
4124 }

被这些函数引用 TEST().

◆ TEST()

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

在文件 pat_test.cpp1994 行定义.

1994 {
1995 istringstream in("12345");
1996 auto out = ostringstream();
1997 main(in, out);
1998 ASSERT_EQ("one five", out.str());
1999 }
int main(int argc, char **argv)
Definition: main.cpp:5

引用了 main().