mramine364

complex main test

Jul 4th, 2016
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.30 KB | None | 0 0
  1. #include<iostream>
  2. #include<time.h>
  3. #include<string>
  4. #include"complex.h"
  5.  
  6. using namespace std;
  7.  
  8. int main(){
  9.     clock_t start_t = clock();
  10.    
  11.     complex* a = new complex(5.0, 6.0);
  12.     complex* b = new complex(-3.0, 4.0);
  13.     complex* c = *a + *b;
  14.     complex* d = *a - *b;
  15.     complex* e = *a * *b;
  16.     complex* e2 = *b * *a;
  17.     complex* f = *a / *b;
  18.     complex* g = *f * *b;
  19.     complex* h = a->conjugate();
  20.     complex* j = a->tangent();
  21.     complex* k = a->sinus();
  22.     complex* l = a->cosinus();
  23.  
  24.     cout << "a            = " << *a << endl;
  25.     cout << "b            = " << *b << endl;
  26.     cout << "Re(a)        = " << (*a).re() << endl;
  27.     cout << "Im(a)        = " << (*a).im() << endl;
  28.     cout << "b + a        = " << *c << endl;
  29.     cout << "a - b        = " << *d << endl;
  30.     cout << "a * b        = " << *e << endl;
  31.     cout << "b * a        = " << *e2 << endl;
  32.     cout << "a / b        = " << *f << endl;
  33.     cout << "(a / b) * b  = " << *g << endl;
  34.     cout << "conj(a)      = " << *h << endl;
  35.     cout << "|a|          = " << a->abs() << endl;
  36.     cout << "a            = " << *a << endl;
  37.     cout << "tan(a)       = " << *j << endl;
  38.     cout << "sin(a)       = " << *k << endl;
  39.     cout << "cos(a)       = " << *l << endl;
  40.  
  41.     delete a, b, c, d, e, e2, f, g, h, j;
  42.  
  43.     cout << "execution in " << clock() - start_t << " ms \n";
  44.     getchar();
  45.     return 0;
  46. }
Advertisement
Add Comment
Please, Sign In to add comment