Advertisement
Guest User

Untitled

a guest
May 25th, 2016
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. #include <iostream>
  2. #include <ctime>
  3. #include <math.h>
  4. #include <iomanip>
  5. using namespace std;
  6. int x[4][5], max = 0, counter = 0, min = 0;
  7. int vishislenie(int arr[4][5])
  8. {
  9. for (int i = 0; i < 4; i++)
  10. for (int j = 0; j < 5; j++)
  11. {
  12. if (arr[i][j] < 0)
  13. counter++;
  14. }
  15. return counter;
  16. }
  17.  
  18. int main()
  19. {
  20. setlocale(0, "");
  21. srand(time(NULL));
  22. for (int i = 0; i < 4; i++)
  23. {
  24. for (int j = 0; j < 5; j++)
  25. {
  26. x[i][j] = -2 + rand() % 8;
  27. cout << setw(7) << x[i][j];
  28. }
  29. cout << endl;
  30. }
  31.  
  32. int max = x[0][0], sum = 0;
  33.  
  34. for (int i = 0; i < 4; i++)
  35. {
  36. for (int j = 0; j < 5; j++)
  37. {
  38. if (max < x[i][j])
  39. max = x[i][j];
  40. }
  41. sum += max;
  42. max = x[i][0];
  43. }
  44. cout << "Cумма максимальных: " << sum << endl;
  45. cout << "Количество минимальных: " << vishislenie(x) << endl;
  46.  
  47. cout << endl;
  48. system("pause");
  49. return 0;
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement