|
|
1.1 root 1: #include "complex.h"
2:
3: ostream& operator<<(ostream& s, complex a)
4: {
5: return s<<"( "<<real(a)<<", "<<imag(a)<<")";
6: }
7:
8: istream& operator>>(istream& s, complex& a)
9: /*
10: f
11: ( f )
12: ( f , f )
13: */
14: {
15: double re = 0, im = 0;
16: char c = 0;
17:
18: s>>c;
19: if (c == '(') {
20: s>>re>>c;
21: if (c == ',') s>>im>>c;
22: if (c != ')') s.clear(_bad);
23: }
24: else {
25: s.putback(c);
26: s>>re;
27: }
28:
29: if (s) a = complex(re,im);
30: return s;
31: }
32:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.