Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cstdlib>
- #include <iostream>
- #include <vector>
- using namespace std;
- int main(int argc, char *argv[]) {
- int matrix[4][5];
- cout << "Enter the elements of array: " << endl << endl;
- for (int j = 0; j < (sizeof(matrix) / sizeof(*matrix)); j++) {
- for (int i = 0; i < (sizeof(matrix[0]) / sizeof(*matrix[0])); i++) {
- cin >> matrix[j][i];
- }
- if (j != ((sizeof(matrix) / sizeof(*matrix)) - 1)) {
- cout << "------------------" << endl;
- } else {
- cout << endl;
- cout << "==================" << endl;
- cout << endl;
- }
- }
- vector<int> passes;
- for (int j = 0; j < (sizeof(matrix) / sizeof(*matrix)); j++) {
- for (int i = 0; i < (sizeof(matrix[0]) / sizeof(*matrix[0])); i++) {
- if (matrix[j][i] < 0) {
- passes.push_back(j);
- }
- }
- }
- vector<int> results;
- int num;
- for (int j = 0; j < passes.size(); j++) {
- num = 0;
- for (int i = 0; i < (sizeof(matrix[0]) / sizeof(*matrix[0])); i++) {
- num += matrix[passes[j]][i];
- }
- results.push_back(num);
- }
- if (results.size() != 0) {
- int num = 0;
- for (int i = 0; i < results.size(); i++) {
- if (results[i] > num) {
- num = results[i];
- }
- }
- cout << "Result is " << num << endl;
- } else {
- cout << "Not found" << endl;
- }
- cout << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement