Advertisement
Guest User

Untitled

a guest
Feb 18th, 2020
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. #include "pch.h"
  2. #include <iostream>
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. int m, n, sum;
  8. int amount = 0;
  9. cout << "vvedite N: "; cin >> n;
  10. cout << "vvedite M: "; cin >> m;
  11. int **arr = new int*[n];
  12. for (int i = 0; i < n; i++)
  13. {
  14. arr[i] = new int[m];
  15. }
  16.  
  17. for (int i = 0; i < n; i++) {
  18. for (int j = 0; j < m; j++) {
  19. cout << "a[" << i + 1 << "][" << j + 1 << "]= ";
  20. cin >> arr[i][j];
  21. }
  22. }
  23. for (int i = 0; i < n; i++) {
  24. for (int j = 0; j < m; j++) {
  25. cout << arr[i][j] << " ";
  26. }
  27. cout << endl;
  28. }
  29. for (int i = 0; i < n; i++) {
  30. for (int j = 0; j < m; j++) {
  31. if (arr[i][j]<0)
  32. {
  33. sum = arr[i][j];
  34. amount = 1;
  35. break;
  36. }
  37. break;
  38. }
  39. break;
  40. }
  41. if (amount == 0)
  42. {
  43. cout << "NETU" << endl;
  44. }
  45. else {
  46. sum = 0;
  47. amount = 0;
  48. for (int i = 0; i < n; i++) {
  49. for (int j = 0; j < m; j++) {
  50. if (arr[i][j] < 0)
  51. {
  52. sum = sum + arr[i][j];
  53. amount = amount+ 1;
  54.  
  55. }
  56. }
  57. }
  58. cout << " sum " << sum << endl;
  59. cout << " amount " << amount << endl;
  60. }
  61.  
  62.  
  63.  
  64.  
  65.  
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement