Advertisement
Kevin_Zhang

Untitled

Jul 31st, 2022 (edited)
976
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.74 KB | None | 0 0
  1. #ifndef STRUCT06_H_
  2. #define STRUCT06_H_
  3.  
  4. #include <iostream>
  5. #include <string>
  6. #include <typeinfo>
  7. #include <cassert>
  8. using namespace std;
  9.  
  10. ostream& operator<<(ostream& os, const complex& cp)
  11. {
  12.     os << cp.real << " " << cp.imaginary;
  13.     return os;
  14. }
  15.  
  16. istream& operator>>(istream& is, complex& cp)
  17. {
  18.     is >> cp.real >> cp.imaginary;
  19.     return is;
  20. }
  21. inline void instruction(){
  22.     complex cp1, cp2;
  23.     cin >> cp1 >> cp2;
  24.     cout << cp1 + cp2 << endl;
  25.     cout << cp1 - cp2 << endl;
  26.     cout << cp1 * cp2 << endl;
  27.     cout << cp1 / cp2 << endl;
  28. }
  29.  
  30. int main() {
  31.     ios_base::sync_with_stdio(0);
  32.     cin.tie(0);
  33.     int N;
  34.     cin >> N;
  35.     while(N--){
  36.         instruction();
  37.     }
  38. }
  39.  
  40.  
  41. #endif // STRUCT06_H_
  42.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement