Advertisement
Guest User

Untitled

a guest
May 23rd, 2019
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.92 KB | None | 0 0
  1. #include <iostream>
  2. #include <locale>
  3. #include <cmath>
  4. using namespace std;
  5.  
  6.  
  7. void inputArrAndCountSum(int* &arr, int n){
  8.     arr = new int[n];
  9.     cout << "Вводите массив:\n";
  10.     for(int i = 0 ; i < n; ++i) cin >> arr[i];
  11. }
  12.  
  13. double s(int *arr, int n){
  14.     int sum = 0;
  15.     for(int i = 0; i < n; ++i){
  16.         sum+=arr[i]*arr[i];
  17.     }
  18.     return sqrt(sum);
  19. }
  20.  
  21.  
  22.  
  23. int main()
  24. {
  25.     int *a, *b, *c;
  26.     int n[3] = {0};
  27.     setlocale(LC_ALL, "");
  28.     cout << "Размерность первого массива: ";
  29.     cin >> n[0];
  30.     inputArrAndCountSum(a, n[0]);
  31.     cout << "Размерность второго массива: ";
  32.     cin >> n[1];
  33.     inputArrAndCountSum(b, n[1]);
  34.     cout << "Размерность третьего массива: ";
  35.     cin >> n[2];
  36.     inputArrAndCountSum(c, n[2]);
  37.     cout << "p = " << s(a, n[0]) + s(b, n[1]) + s(c, n[2]);
  38.     return 0;
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement