mashlukashova

Untitled

Apr 26th, 2019
122
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <vector>
  3. using namespace std;
  4.  
  5. int main (){
  6. int x;
  7. int y;
  8. int mass;
  9. int m_sum = 0;
  10. int x_dop_sum = 0;
  11. int y_dop_sum = 0;
  12. int x_sum = 0;
  13. int y_sum = 0;
  14. vector <int> sum_po_x;
  15. vector <int> sum_po_y;
  16. int n; //кол-во эл в векторе
  17. cout << "vvedite kol-vo el v vectore: " << endl;
  18. cin >> n;
  19. int m;
  20. cout << "vvedite kol-vo tochek: " << endl;
  21. cin >> m;
  22.  
  23. for (int i = 0; i < m; i++){
  24. cout << "dlja tochki" << i + 1 << endl;
  25. int vector_x[n];
  26.  
  27. cout << "vvedite x: " << endl;
  28. for (int j = 0; j < n; j++){
  29. cin >> vector_x[j];
  30.  
  31.  
  32. }
  33. int vector_y[n];
  34.  
  35. cout << "vvedite y: " << endl;
  36. for (int j = 0; j < n; j++){
  37. cin >> vector_y[j];
  38.  
  39. }
  40. int vector_m[n];
  41.  
  42. cout << "vvedite m: " << endl;
  43. for (int j = 0; j < n; j++){
  44. cin >> vector_m[j];
  45.  
  46. m_sum += vector_m[j];
  47. }
  48.  
  49. for (int j = 0; j < n; j++){
  50. x_dop_sum += vector_x[j] * vector_m[j];
  51. }
  52. x_sum += x_dop_sum / m_sum;
  53.  
  54. sum_po_x.push_back(x_sum);
  55.  
  56.  
  57. for (int j = 0; j < n; j++){
  58. y_dop_sum += vector_y[j] * vector_m[j];
  59. }
  60. y_sum += y_dop_sum / m_sum;
  61.  
  62. sum_po_y.push_back(y_sum);
  63.  
  64.  
  65. }
  66. cout << "po x: " << x_sum << endl << "po y: " << y_sum << endl;
  67.  
  68. }
RAW Paste Data