Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- int const m = 5;
- int const n = 5;
- int a[m][n];
- int c = 0;
- int i, j;
- int sum = 0;
- srand(time(0));
- for (i = 0; i < m; i++) { //создаём матрицу
- for (j = 0; j < n; j++) {
- a[i][j] = 20 + rand() % 100;
- cout << a[i][j] << "\t";
- }
- cout << endl;
- }
- for (j = 0; j < n; j++) { //прогоняемся по 4ой строке
- if (a[3][j] % 3 == 0) {
- sum = sum + a[3][j];
- c++;
- }
- }
- cout << "\n";
- cout << "Arithmetic mean of the elements of the 4th row that are multiples of 3: " << sum / c << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement