Advertisement
93willy

Untitled

Feb 14th, 2012
358
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.42 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. #include <complex>
  4.  
  5. using namespace std;
  6.  
  7. typedef complex<double> vect;
  8.  
  9. double dot(vect &a, vect &b)
  10. {
  11.     return real(conj(a)*b);
  12. }
  13.  
  14. int main()
  15. {
  16.     double a1,a2,b1,b2;
  17.     cin >> a1 >> a2 >> b1 >> b2;
  18.  
  19.     vect a(a1,a2), b(b1,b2);
  20.  
  21.     //cout << dot(a,b) << '\n';
  22.  
  23.     double ang = acos( dot(a,b) / (abs(a)*abs(b)) );
  24.     cout.precision(5);
  25.  
  26.     cout << fixed << ang << '\n';
  27.     return 0;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement