Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #include <iostream>
- #include "windows.h"
- #include "time.h"
- using namespace std;
- void main()
- {
- SetConsoleCP(1251);
- SetConsoleOutputCP(1251);
- const int n = 5, m = 5;
- int a[n][m];
- srand(time(NULL));
- for (int i = 0; i < n; i++) {
- srand(rand() % 100);
- for (int j = 0; j < m; j++) {
- a[i][j] = rand() % 10 - 5;
- }
- }
- for (int i = 0; i < n; i++) {
- for (int j = 0; j < m; j++) {
- cout << a[i][j] << " ";
- }
- cout << endl;
- }
- int k, pr;
- for (int i = 0; i < n; i += 2) {
- k = 0;
- pr = 1;
- for (int j = 0; j < m; j++) {
- if (a[i][j] < 0) {
- k++;
- pr *= a[i][j];
- }
- }
- if (pr < 0) {
- for (int j = 0; j < m; j++) {
- a[i][j] = 0;
- }
- }
- }
- cout << endl;
- for (int i = 0; i < n; i++) {
- for (int j = 0; j < m; j++) {
- cout << a[i][j] << " ";
- }
- cout << endl;
- }
- system("pause");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement