avukas

complex 2b

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