Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- int const m = 5;
- int const n = 5;
- int a[m][n];
- int c;
- int i, j;
- srand(time(0));
- cout << "Initial array" << endl;
- for (i = 0; i < m; i++) //начало
- {
- for (j = 0; j < n; j++)
- {
- a[i][j] = rand() % 10;
- cout << a[i][j] << "\t";
- }
- cout << endl;
- }
- for (i = 0; i < m; i++)
- {
- c = 0;
- for (j = 0; j < n; j++)
- {
- if (a[i][j] % 2 == 0) {
- a[i][j] = a[i][j] + a[i][0];
- }
- }
- } //конец
- cout << "\n" << "Answer for (a)" << endl;
- for (i = 0; i < m; i++) //вывод итога для а
- {
- for (j = 0; j < n; j++)
- {
- cout << a[i][j] << "\t";
- }
- cout << endl;
- }
- for (i = 0; i < m; i++)
- {
- c = 0;
- for (j = 0; j < n; j++)
- {
- if (a[i][j] % 10 == 2) {
- a[i][j] = a[i][j] * a[i][n - 1];
- }
- }
- }
- cout << "\n" << "Answer for (b)" << endl;
- for (i = 0; i < m; i++) //вывод итога для б
- {
- for (j = 0; j < n; j++)
- {
- cout << a[i][j] << "\t";
- }
- cout << endl;
- }
- for (i = 0; i < m; i++)
- {
- c = 0;
- for (j = 0; j < n; j++)
- {
- if (a[i][j] > 0) {
- a[i][j] = a[i][j] + a[i][n - 1];
- }
- else {
- a[i][j] = a[i][j] + a[i][0];
- }
- }
- }
- cout << "\n" << "Answer for (c)" << endl;
- for (i = 0; i < m; i++) //вывод итога для в
- {
- for (j = 0; j < n; j++)
- {
- cout << a[i][j] << "\t";
- }
- cout << endl;
- }
- for (i = 0; i < m; i++)
- {
- c = 0;
- for (j = 0; j < n; j++)
- {
- if ((i + j + 2) % 5 == 0) {
- a[i][j] = 0;
- }
- }
- }
- cout << "\n" << "Answer for (d)" << endl;
- for (i = 0; i < m; i++) //вывод итога для г
- {
- for (j = 0; j < n; j++)
- {
- cout << a[i][j] << "\t";
- }
- cout << endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement