Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- const int n = 10;
- int main() {
- int arr[n][n];
- double average[n];
- for (int i = 0; i < n; i++) {
- for (int j = 0; j < n; j++) {
- arr[i][j] = rand()%10 - 8;
- std::cout << arr[i][j] << "\t";
- }
- std::cout << std::endl;
- }
- int sum = 0;
- for (int i = 0; i < n; i++) {
- if (arr[i][i] > 0) {
- for (int j = 0; j < n; j++) {
- sum += arr[j][i];
- }
- average[i] = sum / n;
- sum = 0;
- }
- else { average[i] = 0; }
- std::cout << average[i] << "\t";
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement