Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #include <cstdlib>
- #include <iostream>
- #include <iomanip>
- #include <clocale>
- #include <cmath>
- using namespace std;
- void sedl(int **a, int n, int m) {
- for (int i = 0; i < n; i++) {
- int min = 0;
- bool flag = 1;
- for (int j = 0; j < m; j++) {
- if (a[i][min] > a[i][j]) {
- min = j;
- }
- }
- for (int j = 0; j < m; j++){
- if (a[i][j] == min){
- for (int z = 0; (z < n) && flag; z++) {
- if (a[i][min] < a[z][min]) {
- flag = 0;
- }
- }
- if (flag) cout << "Столбец: " << min << " Строка: " << i << endl;
- }
- }
- }
- }
- void sum(int **a, int n, int m) {
- int summa = 0, num = -1;
- bool flag = 0;
- for (int i = 0; i < n; i++) {
- for (int j = 0; j < m; j++) {
- summa += a[i][j];
- if (a[i][j] < 0) {
- num = i;
- flag = 1;
- }
- }
- if (flag) {
- cout << "Сумма строки " << i << ": " << summa;
- }
- else cout << "В строке " << i << " нет отрицательных элементов";
- summa = 0;
- flag = 0;
- cout << endl;
- }
- }
- void input(int **a, int n, int m) {
- for (int i = 0; i < n; i++) {
- for (int j = 0; j < m; j++)
- cin >> a[i][j];
- }
- }
- void output(int **a, int n, int m) {
- for (int i = 0; i < n; i++) {
- for (int j = 0; j < m; j++)
- cout << setw(4) << a[i][j];
- cout << endl;
- }
- }
- int _tmain(int argc, _TCHAR* argv[])
- {
- setlocale(LC_ALL, "rus");
- int n, m;
- cout << "Введите размер массива: ";
- cin >> n >> m;
- int **a = new int*[n];
- for (int i = 0; i < n; i++)
- a[i] = new int[m];
- input(a, n, m);
- output(a, n, m);
- sum(a, n, m);
- sedl(a, n, m);
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement