Advertisement
sellmmaahh

popravni-2013-zad2

Jul 28th, 2015
208
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.81 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <complex>
  4.  
  5. using namespace std;
  6. void Smjesti (vector<complex<double>> vek, vector<double> &mod, vector<double> &argumenti)
  7. {
  8.     mod.resize(vek.size());
  9.     argumenti.resize(vek.size());
  10.     for (int i=0; i<vek.size(); i++) {
  11.         mod[i]=abs(vek[i]);
  12.         argumenti[i]=arg(vek[i]);
  13.     }
  14. }
  15.  
  16. int main () {
  17. cout<<"Unesite broj elemenata: ";
  18. int n;
  19. cin>>n;
  20. cout<<"Unesite kompleksne brojeve u obliku: (x,y) ";
  21. vector<complex<double>> v(0);
  22. complex<double> z;
  23. for (int i=0; i<n; i++)
  24. {
  25.     cin>>z;
  26.     v.push_back(z);
  27. }
  28. vector<double> a(0);
  29. vector<double> b(0);
  30. Smjesti(v,a,b);
  31. cout<<"Moduli kompleksnih brojeva: ";
  32. for (auto x: a) cout<<x<<" ";
  33. cout<<endl;
  34. cout<<"Argumenti kompleksnih brojeva: ";
  35. for (auto y: b) cout<<y<<" ";
  36. return 0;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement