Advertisement
wowonline

Untitled

Apr 13th, 2022
979
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.99 KB | None | 0 0
  1. #include "cmc_complex_eval.h"
  2. #include "cmc_complex.h"
  3. #include "cmc_complex_stack.h"
  4. #include <iostream>
  5. #include <string>
  6. #include <cmath>
  7. #include <vector>
  8.  
  9. int main(int argc, char *argv[])
  10. {
  11.     // // if (argc < 3) {
  12.     // //     return 0;
  13.     // // }
  14.     int N = std::stoi((std::string(argv[3])));
  15.     double step = M_PI * 2 / N;
  16.     double R = std::stod((std::string(argv[2])));
  17.     numbers::complex C((std::string(argv[1])));
  18.  
  19.     std::vector<std::string> vec;
  20.     for (int i = 4; i < argc; ++i) {
  21.         vec.push_back((std::string(argv[i])));
  22.     }
  23.  
  24.     numbers::complex I(0, 0);
  25.     numbers::complex last(R + C.re(), C.im()), tmp;
  26.  
  27.     for (int i = 1; i < N+1; ++i) {
  28.         tmp = numbers::complex(cos((i - 0.5) * step) * R + C.re(), sin((i - 0.5) * step) * R + C.im());
  29.         last = tmp;
  30.         I += numbers::eval(vec, tmp) * step * numbers::complex(-R * sin((i - 0.5) * step), R * cos((i - 0.5) * step));
  31.     }
  32.  
  33.     std::cout << I.to_string() << std::endl;
  34. }
  35.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement