fork download
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. struct LiczbaZespolona {
  6. double re;
  7. double im;
  8. };
  9.  
  10. struct Wektor {
  11. LiczbaZespolona x;
  12. LiczbaZespolona y;
  13. };
  14.  
  15. ostream &operator<<(ostream &wyjscie, const LiczbaZespolona &Zesp) {
  16. wyjscie << "(" << Zesp.re << showpos << Zesp.im << noshowpos << "i)";
  17.  
  18. return wyjscie;
  19. }
  20.  
  21. ostream &operator<<(ostream &wyjscie, const Wektor &V) {
  22. // Od razu widac, ze cos jest nie tak:
  23. // wyjscie << "( " < V.x << ", " << V.y << " )";
  24. wyjscie << "( " << V.x << ", " << V.y << " )";
  25.  
  26. return wyjscie;
  27. }
  28.  
  29. void Test(){
  30. // W C++11 na pewno można tak:
  31. Wektor V = { {7, 8}, {4, 12} };
  32.  
  33. cout << V << '\n';
  34. }
  35.  
  36. int main() {
  37. Test();
  38.  
  39. return 0;
  40. }
Success #stdin #stdout 0s 2852KB
stdin
Standard input is empty
stdout
(  (7+8i),  (4+12i)  )