Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <conio.h>
- #include <time.h>
- using namespace std;
- int main() {
- const int n = 4;
- int a[n][n];
- double b[n];
- srand(time(NULL));
- for (int i = 0; i < n; i++) {
- for(int j = 0; j < n; j++) {
- a[i][j] = rand() % 10 - 2;
- cout << a[i][j] << " ";
- }
- cout << endl;
- }
- cout << endl;
- for (int i = 0; i < n; i++) {
- double s = 0;
- for(int j = 0; j < n; j++)
- s += a[i][j];
- b[i] = s / n;
- }
- cout << endl;
- cout.precision(4);
- for (int i = 0; i < n; i++)
- cout << b[i] << " ";
- cout << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment