Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <complex>
- using namespace std;
- void Smjesti (vector<complex<double>> vek, vector<double> &mod, vector<double> &argumenti)
- {
- mod.resize(vek.size());
- argumenti.resize(vek.size());
- for (int i=0; i<vek.size(); i++) {
- mod[i]=abs(vek[i]);
- argumenti[i]=arg(vek[i]);
- }
- }
- int main () {
- cout<<"Unesite broj elemenata: ";
- int n;
- cin>>n;
- cout<<"Unesite kompleksne brojeve u obliku: (x,y) ";
- vector<complex<double>> v(0);
- complex<double> z;
- for (int i=0; i<n; i++)
- {
- cin>>z;
- v.push_back(z);
- }
- vector<double> a(0);
- vector<double> b(0);
- Smjesti(v,a,b);
- cout<<"Moduli kompleksnih brojeva: ";
- for (auto x: a) cout<<x<<" ";
- cout<<endl;
- cout<<"Argumenti kompleksnih brojeva: ";
- for (auto y: b) cout<<y<<" ";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement