#include <iostream>
#include <vector>
#include <cstdlib>
#include <ctime>
using namespace std;
int main() {
srand(time(0));
setlocale(LC_ALL, "Russian");
vector< vector<int> > arr;
vector<float> average;
float result = 0;
arr.resize(10);
for (int i = 0; i < arr.size(); ++i) {
arr[i].resize(10);
}
for (int j = 0; j < arr[i].size(); ++j) {
arr[i][j] = rand()%10;
cout << arr[i][j] << " ";
if (j == arr[i].size() - 1) {
cout << endl;
if (arr[i][arr[i].size() - 1] == 1) {
average.push_back(arr[i][j]);
for (int i = 0; i < average.size(); ++i) {
result += average[i];
if (average.size() == 0) {
cout << endl << "Единицы отсутствуют.";
return 0;
result /= average.size();
cout << result;
#include <iostream>
#include <vector>
#include <cstdlib>
#include <ctime>
using namespace std;
int main() {
srand(time(0));
setlocale(LC_ALL, "Russian");
vector< vector<int> > arr;
vector<float> average;
float result = 0;
arr.resize(10);
for (int i = 0; i < arr.size(); ++i) {
arr[i].resize(10);
}
for (int i = 0; i < arr.size(); ++i) {
for (int j = 0; j < arr[i].size(); ++j) {
arr[i][j] = rand()%10;
cout << arr[i][j] << " ";
if (j == arr[i].size() - 1) {
cout << endl;
}
}
}
for (int i = 0; i < arr.size(); ++i) {
if (arr[i][arr[i].size() - 1] == 1) {
for (int j = 0; j < arr[i].size(); ++j) {
average.push_back(arr[i][j]);
}
}
}
for (int i = 0; i < average.size(); ++i) {
result += average[i];
}
if (average.size() == 0) {
cout << endl << "Единицы отсутствуют.";
return 0;
}
result /= average.size();
cout << result;
}