avukas

complex c

Mar 12th, 2014
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. #include <iostream>
  2. #include <complex>
  3. #include <cmath>
  4.  
  5.  
  6.  
  7. int main()
  8. {
  9. std::cout<<"Unesite broj elemenata:\n ";
  10. int n;
  11. std::cin>>n;
  12.  
  13. double z, fi;
  14. std::complex<double> Z, priprema(1,0), X;
  15.  
  16. int i(0);
  17. const double PI (3.14);
  18. while (i!=n)
  19. {
  20. std::cout<<" Unesite Z" << i + 1 << "\n";
  21. std::cin>>z;
  22. std::cout<<"Unesite fi"<< i + 1 << "\n";
  23. std::cin>>fi;
  24. fi=fi*180/PI;
  25. Z=std::polar(z, fi);
  26.  
  27. priprema=priprema+std::complex<double> (1,0)/Z;
  28. i++;
  29.  
  30. }
  31. X=std::complex<double> (1,0)/priprema;
  32. double fi1;
  33. fi1=arg(X);
  34. fi1=fi1*180/PI;
  35.  
  36. std::cout<< "Paralelna veza ovih elemenata ima Z = " << sqrt(X.real() * X.real() + X.imag() * X.imag())
  37. << " i fi = "<< fi1 << std::endl;
  38.  
  39.  
  40. return 0;
  41. }
Advertisement
Add Comment
Please, Sign In to add comment