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

1010 一元多项式求导 更多...

函数

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

详细描述

1010 一元多项式求导

函数说明

◆ main()

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

在文件 pat.cpp300 行定义.

300 {
301 int num;
302 vector<int> vec;
303 ostringstream oss;
304 while(cin >> num) {
305 vec.push_back(num);
306 }
307 for(int i = 0; i + 1 < vec.size(); i += 2) {
308 const int a = vec[i] * vec[i + 1];
309 const int b = vec[i + 1] - 1;
310 if(vec[i + 1] != 0) {
311 oss << a << ' ' << b << ' ';
312 }
313 }
314 if(vec.size() == 2 && vec[1] == 0) {
315 oss << "0 0 ";
316 }
317 string ans = oss.str();
318 ans = ans.substr(0, ans.length() - 1);
319 cout << ans;
320 return 0;
321 }
int vec[100010]
Definition: pat.cpp:5095

引用了 pat::a::a7_2::vec.

被这些函数引用 TEST().

◆ TEST()

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

在文件 pat_test.cpp134 行定义.

134 {
135 istringstream in("3 4 -5 2 6 1 -2 0");
136 auto out = ostringstream();
137 main(in, out);
138 const auto ans = out.str();
139 ASSERT_EQ("12 3 -10 1 6 0", ans);
140 }
int main(int argc, char **argv)
Definition: main.cpp:5

引用了 main().