Advertisement
Courbe_Impliquee

Функция 5

Mar 15th, 2019
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.65 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include <cstdlib>
  3. #include <iostream>
  4. #include <iomanip>
  5. #include <clocale>
  6. #include <cmath>
  7. using namespace std;
  8. void sedl(int **a, int n, int m) {
  9. for (int i = 0; i < n; i++) {
  10. int min = 0;
  11. bool flag = 1;
  12. for (int j = 0; j < m; j++) {
  13. if (a[i][min] > a[i][j]) {
  14. min = j;
  15. }
  16. }
  17. for (int j = 0; j < m; j++){
  18. if (a[i][j] == min){
  19. for (int z = 0; (z < n) && flag; z++) {
  20. if (a[i][min] < a[z][min]) {
  21. flag = 0;
  22. }
  23. }
  24. if (flag) cout << "Столбец: " << min << " Строка: " << i << endl;
  25. }
  26. }
  27. }
  28. }
  29. void sum(int **a, int n, int m) {
  30. int summa = 0, num = -1;
  31. bool flag = 0;
  32. for (int i = 0; i < n; i++) {
  33. for (int j = 0; j < m; j++) {
  34. summa += a[i][j];
  35. if (a[i][j] < 0) {
  36. num = i;
  37. flag = 1;
  38. }
  39. }
  40. if (flag) {
  41. cout << "Сумма строки " << i << ": " << summa;
  42. }
  43. else cout << "В строке " << i << " нет отрицательных элементов";
  44. summa = 0;
  45. flag = 0;
  46. cout << endl;
  47. }
  48. }
  49. void input(int **a, int n, int m) {
  50. for (int i = 0; i < n; i++) {
  51. for (int j = 0; j < m; j++)
  52. cin >> a[i][j];
  53. }
  54. }
  55. void output(int **a, int n, int m) {
  56. for (int i = 0; i < n; i++) {
  57. for (int j = 0; j < m; j++)
  58. cout << setw(4) << a[i][j];
  59. cout << endl;
  60. }
  61. }
  62. int _tmain(int argc, _TCHAR* argv[])
  63. {
  64. setlocale(LC_ALL, "rus");
  65. int n, m;
  66. cout << "Введите размер массива: ";
  67. cin >> n >> m;
  68. int **a = new int*[n];
  69. for (int i = 0; i < n; i++)
  70. a[i] = new int[m];
  71. input(a, n, m);
  72. output(a, n, m);
  73. sum(a, n, m);
  74. sedl(a, n, m);
  75. system("pause");
  76. return 0;
  77. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement