📄 stllist.cpp
字号:
// Filename: STLlist.cpp#include <iostream>#include <list> //list container#include <numeric> //for accumulateusing namespace std;//using an iterator to traverse lstvoid display(const list<double> &lst) { list<double>::const_iterator p; for (p = lst.begin(); p !=lst.end(); ++p) cout << *p << '\t'; cout << endl;}int main() { double w[4] = {0.9, 0.8, 88, -99.99}; list<double> z; for (int i = 0; i < 4; ++i) z.push_front(w[i]); display(z); z.sort(); display(z); cout << "sum is " << accumulate(z.begin(), z.end(), 0.0) << endl; return 0;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -