PuddleCreek

Untitled

Nov 13th, 2019
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <vector>
  4. #define Reset(x) x = 0
  5. #define Write(x) std::cout << x << std::endl;
  6. #define Read(x) std::cin >> x;
  7.  
  8. class Vector
  9. {
  10. public:
  11. static double Module(std::vector<int> v)
  12. {
  13. double S = 0;
  14. for(int i = 0; i <= v.size() - 1; i++)
  15. {
  16. S += (v[i]) ^ 2;
  17. }
  18. return S;
  19. }
  20. };
  21.  
  22. void PrintVector(std::vector<int> v)
  23. {
  24. std::string str = "";
  25. for (int i = 0; i < v.size(); i++)
  26. {
  27. std::cout << v.at(i) << " ";
  28. }
  29. }
  30.  
  31. int main()
  32. {
  33. int vect1 = 0,
  34. vect2 = 0,
  35. input = 0;
  36. std::vector<int> vectors[3];
  37.  
  38. vectors[0] = { 1, 2, 3 };
  39. vectors[1] = { 3 ,2 ,1 };
  40. vectors[2] = { 1, 2, 3, 4 };
  41.  
  42. std::cout << "1 vector: { 1 , 2, 3 }" << std::endl;
  43. std::cout << "2 vector: { 3 , 2, 1 }" << std::endl;
  44. std::cout << "3 vector: { 1, 2, 3, 4 }" << std::endl;
  45.  
  46. std::cout << "Choose an operation: \n";
  47. Read(input);
  48.  
  49. switch(input)
  50. {
  51. case 1: //Module
  52. Write("Choose a vector: ");
  53. Read(vect1);
  54. Write(Vector::Module(vectors[vect1 - 1]));
  55. break;
  56. }
  57.  
  58. system("pause");
  59. }
Advertisement
Add Comment
Please, Sign In to add comment