Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <ctime>
- #include <math.h>
- #include <iomanip>
- using namespace std;
- int x[4][5], max = 0, counter = 0, min = 0;
- int vishislenie(int arr[4][5])
- {
- for (int i = 0; i < 4; i++)
- for (int j = 0; j < 5; j++)
- {
- if (arr[i][j] < 0)
- counter++;
- }
- return counter;
- }
- int main()
- {
- setlocale(0, "");
- srand(time(NULL));
- for (int i = 0; i < 4; i++)
- {
- for (int j = 0; j < 5; j++)
- {
- x[i][j] = -2 + rand() % 8;
- cout << setw(7) << x[i][j];
- }
- cout << endl;
- }
- int max = x[0][0], sum = 0;
- for (int i = 0; i < 4; i++)
- {
- for (int j = 0; j < 5; j++)
- {
- if (max < x[i][j])
- max = x[i][j];
- }
- sum += max;
- max = x[i][0];
- }
- cout << "Cумма максимальных: " << sum << endl;
- cout << "Количество минимальных: " << vishislenie(x) << endl;
- cout << endl;
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement