Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cmath>
- #include <cstdio>
- #include <vector>
- #include <iostream>
- #include <algorithm>
- using namespace std;
- bool isSmallestInRow(int row, int col, int** matrix, int rowsCount, int colsCount) {
- for (int i = 0; i < colsCount; i++) {
- if (matrix[row][col] > matrix[row][i]) {
- return false;
- }
- }
- return true;
- }
- bool isBiggestInCol(int row, int col, int** matrix, int rowsCount, int colsCount) {
- for (int i = 0; i < rowsCount; i++) {
- if (matrix[row][col] < matrix[i][col]) {
- return false;
- }
- }
- return true;
- }
- int* find(int** matrix, int rowsCount, int colsCount) {
- int * result = new int[rowsCount];
- int index = 0;
- for (int i = 0; i < rowsCount; i++) {
- for (size_t j = 0; j < colsCount; j++)
- {
- if (isSmallestInRow(i, j, matrix, rowsCount, colsCount) && isBiggestInCol(i, j, matrix, rowsCount, colsCount)) {
- result[index++] = matrix[i][j];
- }
- }
- }
- int * finalResult = new int[index];
- for (size_t i = 0; i < index; i++)
- {
- finalResult[i] = result[i];
- }
- return finalResult;
- }
- int main() {
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment