Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- using namespace std;
- int mx(int **arr, int& N, int& M)
- {
- int max;
- max = arr[0][0];
- for (int i = 0; i < N; i++)
- {
- for (int j = 0; j < M; j++)
- {
- if (arr[i][j] >= max)
- {
- max = arr[i][j];
- }
- }
- }
- return max;
- }
- int neg_Q(int** arr, int& N, int& M)
- {
- int neg_Q;
- neg_Q = 0;
- for (int i = 0; i < N; i++)
- {
- for (int j = 0; j < M; j++)
- {
- if (arr[i][j] < 0)
- {
- neg_Q++;
- }
- }
- }
- return neg_Q;
- }
- int R(int rad)
- {
- int p_q = 0;
- int x = 1, y = 1;
- while (x <= rad)
- {
- while (y <= rad)
- {
- if (pow(x, 2) + pow(y, 2) <= pow(rad, 2))
- {
- p_q++;
- }
- }
- }
- p_q *= 4;
- p_q++;
- p_q += 4 * ceil(rad);
- return p_q;
- }
- int main()
- {
- int N, M;
- cin >> N >> M;
- int** arr = new int* [N];
- for (int i = 0; i < N; i++)
- {
- arr[i] = new int[M];
- }
- for (int i = 0; i < N; i++)
- {
- for (int j = 0; j < M; j++)
- {
- cin >> arr[i][j];
- }
- }
- /*for (int i = 0; i < N; i++)
- {
- for (int j = 0; j < M; j++)
- {
- cout << arr[i][j] << " ";
- }
- cout << endl;
- }*/
- int rad;
- cin >> rad;
- cout <<"max = "<< mx(arr, N, M) << endl;
- cout << "Neg_Q = " << neg_Q(arr, N, M) << endl;
- cout << "R = " << R(rad) << endl;
- for (int i = 0; i < N; i++)
- {
- delete[] arr[i];
- }
- delete[] arr;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement