Advertisement
ULK

Лабораторная №9 (12.49а)

ULK
Dec 6th, 2022 (edited)
1,021
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.55 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6.     int const m = 5;
  7.     int const n = 5;
  8.     int a[m][n];
  9.     int sum = 0;
  10.     int i, j;
  11.  
  12.     srand(time(0));
  13.  
  14.     for (i = 0; i < m; i++) {
  15.         for (j = 0; j < n; j++) {
  16.             a[i][j] = 20 + rand() % 100;
  17.             cout << a[i][j] << "\t";
  18.         }
  19.         cout << endl;
  20.     }
  21.  
  22.     for (j = 0; j < n; j++) {
  23.         sum = sum + a[1][j] * a[1][j];
  24.     }
  25.     cout << "\n";
  26.     cout << "Sum of the squares of the elements of the second row of the array: " << sum << endl;
  27. }
  28.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement