• Кр по инфе
    Замените элементы, стоящие на главной диагонали и значения которых четное на цифру 100

Ответы 1

  • #include <iostream>#include <stdlib.h>#include <time.h>using namespace std;const int n = 10;int main(){    int a[n][n];    cout << "Source array: ";    srand(time(NULL));    for (int i = 0; i < n; i++) {        for (int j = 0; j < n; j++) {            a[i][j] = rand() % 500 + 100;            cout << a[i][j] << "  ";        }        cout << endl;    }    cout << "New array: ";    for (int i = 0; i < n; i++) {        for (int j = 0; j < n; j++) {            if ((a[i][j] % 2 == 0) && (i == j))                 a[i][j] = 100;            cout << a[i][j] << "  ";        }        cout << endl;    }    //system("pause");    return 0;}
  • Добавить свой ответ

Войти через Google

или

Забыли пароль?

У меня нет аккаунта, я хочу Зарегистрироваться

How much to ban the user?
1 hour 1 day 100 years