Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main() {
- setlocale(LC_ALL, "ru");
- const int row = 3;
- const int col = 3;
- int arr[row][col];
- srand(time(NULL));
- int sum = 0;
- for (int i = 0; i < row; i++) {
- for (int j = 0; j < col; j++) {
- arr[i][j] = rand() % 10;
- cout << arr[i][j] << '\t';
- }
- cout << endl;
- }
- cout << endl;
- int min = arr[0][0];
- int max = arr[0][0];
- for (int i = 0; i < row; i++) {
- for (int j = 0; j < col; j++) {
- sum += arr[i][j];
- if (arr[i][j] < min) {
- min = arr[i][j];
- }
- if (arr[i][j] > max) {
- max = arr[i][j];
- }
- }
- cout << endl;
- }
- cout << "Сумма всех элементов массива: " << sum << endl;
- cout << "Среднее арифметическое: " << sum / (row * col) << endl;
- cout << "Минимальный элемент: " << min << endl;
- cout << "Максимальный элемент: " << max << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment