Polnochniy

Untitled

Nov 22nd, 2019
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. #include <iostream>
  2. #include <time.h>
  3. using namespace std;
  4. const int N = 3;
  5. int main()
  6. {
  7. srand(time(NULL));
  8. setlocale(LC_ALL, "Rus");
  9. int sum = 0;
  10. int a[N][N];
  11. for (int i = 0; i < N; i++)
  12. {
  13. for (int j = 0; j < N; j++)
  14. {
  15. a[i][j] = rand() % 109+(-37);
  16. }
  17. cout << endl;
  18. }
  19. for (int i = 0; i < N; i++)
  20. {
  21. for (int j = 0; j < N; j++)
  22. {
  23. cout << a[i][j] << "\t";
  24. if (a[i][j] < 0 && j >= i && j >= N - i - 1)
  25. {
  26. sum += a[i][j];
  27. }
  28. }
  29. cout << endl<< endl;
  30. }
  31. cout << endl;;
  32.  
  33. cout << "Сумма отрицательных чисел заштриховкой области : " << sum << "\n";
  34. return 0;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment