Advertisement
Dzham

Untitled

Feb 25th, 2019
193
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.04 KB | None | 0 0
  1. std::size_t nCoefficientsA;
  2. std::cout << "Number of <double> coefficients in the first vector: " << std::endl;
  3. std::cin >> nCoefficientsA;
  4.  
  5. std::vector<double> coefficientsA;
  6. std::cout << "List of coefficients: " << std::endl;
  7. while (coefficientsA.size() < nCoefficientsA) {
  8. double coefficient;
  9. std::cin >> coefficient;
  10. coefficientsA.push_back(coefficient);
  11. }
  12.  
  13. std::size_t nCoefficientsB;
  14. std::cout << "Number of <double> coefficients in the second vector: " << std::endl;
  15. std::cin >> nCoefficientsB;
  16.  
  17. std::vector<double> coefficientsB;
  18. std::cout << "List of coefficients: " << std::endl;
  19. while (coefficientsB.size() < nCoefficientsB) {
  20. double coefficient;
  21. std::cin >> coefficient;
  22. coefficientsB.push_back(coefficient);
  23. }
  24. std::reverse(coefficientsA.begin(), coefficientsA.end());
  25. std::reverse(coefficientsB.begin(), coefficientsB.end());
  26.  
  27. Polynomial<double> A(coefficientsA);
  28. Polynomial<double> B(coefficientsB);
  29. Polynomial<double> C(0);
  30.  
  31. std::cout << "First vector: " << A << std::endl;
  32. std::cout << "Second vector: " << B << std::endl;
  33. std::cout << "Third vector: " << C << std::endl;
  34.  
  35. if (A == B) {
  36. std::cout << "Equal" << std::endl;
  37. } else if (A != B) {
  38. std::cout << "Not Equal" << std::endl;
  39. }
  40.  
  41.  
  42. std::cout << "+ " << A + B << std::endl;
  43.  
  44. std::cout << "- " << A - B << std::endl;
  45. std::cout << "/ : " << (A / B) << std::endl;
  46. std::cout << "% : " << (A % B) << std::endl;
  47. std::cout << ", : " << (A , B) << std::endl;
  48. std::cout << A(-1) << '\n';
  49.  
  50. std::cout << "List of the coefficients before variable degrees from 0 to 19: " << std::endl;
  51. for (int i = 0; i < 20; ++i) {
  52. std::cout << A[i] << " ";
  53. }
  54. std::cout << std::endl;
  55. auto i = A.begin();
  56. while (i != A.end()) {
  57. std::cout << *i++ << " ";
  58. }
  59. std::cout << '\n';
  60. std::cout << A.Degree();
  61. std::cout << '\n';
  62. std::cout << *A.begin();
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement