Advertisement
93willy

Untitled

Feb 14th, 2012
395
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.48 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) / (sqrt(real(a)*real(a)+imag(a)*imag(a))*sqrt(real(b)*real(b)+imag(b)*imag(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