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 & output, const LiczbaZespolona & Zesp ) {
  16.  
  17. output <<"("<<Zesp.re<<showpos<<Zesp.im<<noshowpos<<"i)";
  18.  
  19. return output;
  20. }
  21.  
  22. ostream & operator << ( ostream & wyjscie , const Wektor & V){ // wysw wektor zespolony 2x1
  23.  
  24. wyjscie << "( "<< V.x<<", "<<V.y<<" )"<<endl;
  25.  
  26. return wyjscie;}
  27.  
  28.  
  29. //... dalej w programie
  30.  
  31.  
  32. void Test(){
  33.  
  34. Wektor V; // powiedzmy ze ręcznie przypiszę wartosci
  35. V.x.re=7;
  36. V.x.im=8;
  37. V.y.re=3;
  38. V.y.im=12;
  39.  
  40.  
  41. cout << V<<endl; // chce wyswietlic ladnie wektor
  42. }
  43.  
  44. int main() {
  45. Test();
  46.  
  47. return 0;
  48. }
Success #stdin #stdout 0s 2852KB
stdin
Standard input is empty
stdout
(  (7+8i),  (3+12i)  )