Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <time.h>
- using namespace std;
- const int N = 3;
- int main()
- {
- srand(time(NULL));
- setlocale(LC_ALL, "Rus");
- int sum = 0;
- int a[N][N];
- for (int i = 0; i < N; i++)
- {
- for (int j = 0; j < N; j++)
- {
- a[i][j] = rand() % 109+(-37);
- }
- cout << endl;
- }
- for (int i = 0; i < N; i++)
- {
- for (int j = 0; j < N; j++)
- {
- cout << a[i][j] << "\t";
- if (a[i][j] < 0 && j >= i && j >= N - i - 1)
- {
- sum += a[i][j];
- }
- }
- cout << endl<< endl;
- }
- cout << endl;;
- cout << "Сумма отрицательных чисел заштриховкой области : " << sum << "\n";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment