Debian Codegraph @

yo/containers/examples/complexstack.cc

raw
1 #include <iostream>
2 #include <complex>
3 #include <stack>
4
5 using namespace std;
6
7 int main()
8 {
9 stack<complex<double>>
10 cstack;
11
12 cstack.push(complex<double>(3.14, 2.71));
13 cstack.push(complex<double>(-3.14, -2.71));
14
15 while (cstack.size())
16 {
17 cout << cstack.top().real() << ", " <<
18 cstack.top().imag() << "i" << '\n';
19 cstack.pop();
20 }
21 }
22 /*
23 Generated output:
24 -3.14, -2.71i
25 3.14, 2.71i
26 */