Advertisement
Guest User

Untitled

a guest
Oct 14th, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.68 KB | None | 0 0
  1. //
  2. // main.cpp
  3. // индюк
  4. //
  5. // Created by Mr.Red on Macbook Pro on 14.10.2019.
  6. // Mr.Red Copyright © 2019 . All rights reserved.
  7. // c++ for faggots
  8.  
  9. #include <iostream>
  10. #include <math.h>
  11. using namespace std;
  12. class Vector{
  13. private:
  14. int *koord;
  15. int *koord2;
  16. int *sum;
  17. int *min;
  18. int *min2;
  19. int *mult;
  20. int *mult2;
  21. int value;
  22. public:
  23. int dimension;
  24. void create(int n);
  25. void Sum(int dimension);
  26. void Min(int dimension);
  27. void Mult(int dimension);
  28. void Value(int dimension);
  29. void print(int dimension);
  30. };
  31.  
  32. void Vector::create(int n){
  33.  
  34. dimension = n;
  35. koord = new int[dimension];
  36. for(int i = 0;i<dimension;i++){
  37. cout << "Введите " << i + 1<< "-ую координату первого вектора" << endl;
  38. cin >> koord[i];
  39. }
  40. koord2 = new int[dimension];
  41. for(int i = 0;i<dimension;i++){
  42. cout << "Введите " << i + 1 << "-ую координату второго вектора" << endl;
  43. cin >> koord2[i];
  44. }
  45. }
  46.  
  47. void Vector::Sum(int dimension){
  48. int i;
  49. sum = new int[dimension];
  50. for( i = 0; i < dimension; i++) {
  51. sum[i] = koord[i] + koord2[i];
  52. }
  53. }
  54. void Vector::Min(int dimension){
  55. int i;
  56. min = new int[dimension];
  57. for( i = 0; i < dimension; i++) {
  58. min[i] = koord[i] - koord2[i];
  59. }
  60. min2 = new int[dimension];
  61. for( i = 0; i < dimension; i++) {
  62. min2[i] = koord2[i] - koord[i];
  63. }
  64. }
  65. void Vector::Mult(int dimension){
  66. int i,m;
  67. cout << "Введите число на которое небходимо умножить векторы";
  68. cin >> m;
  69. mult = new int[dimension];
  70. for( i = 0; i < dimension; i++) {
  71. mult[i] = koord[i] * m;
  72. }
  73. mult2 = new int[dimension];
  74. for (i = 0; i < dimension; i++) {
  75. mult2[i] = koord2[i] * m;
  76. }
  77. }
  78. void Vector::Value(int dimension){
  79. for(int i = 0; i < dimension; i++){
  80. value += pow(koord2[i],2);
  81. }
  82. cout << "Модуль вектора " << value <<endl;
  83. }
  84. void Vector::print(int dimension){
  85. int i;
  86. cout << "Сумма векторов : (";
  87. for(i = 0; i < dimension;i++){
  88. cout << sum[i]<<";";
  89. }
  90. cout << ")";
  91. }
  92. int main(int argc, const char * argv[]) {
  93. int n,b;
  94. setlocale(LC_ALL,"ru");
  95. cout << "Введите мерность векторов" <<endl;
  96. cin >> n;
  97. Vector first;
  98.  
  99. first.create(n);
  100. first.Min(first.dimension);
  101. first.Sum(first.dimension);
  102. first.Mult(first.dimension);
  103. first.Value(first.dimension);
  104. first.print(first.dimension);
  105. cin >>b;
  106. return 0;
  107. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement