Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <ctime>
- using namespace std;
- int main()
- {
- srand(time(0)); // инициализация функции rand значением функции time
- const int n = 5; // количество строк
- const int m = 5; // количество столбцов
- int** data = new int*[n];
- for (int i = 0; i < n; i++) {
- data[i] = new int[m];
- for (int j = 0; j < m; j++) {
- data[i][j] = 0;
- }
- }
- /*Начало вашего кода*/
- //TODO: Пишите код тут
- for (int i = 0; i < n; i++) {
- data[i] = new int[m];
- for (int j = 0; j < m; j++) {
- if (i == j) {
- data[i][j] = 1;
- } else {
- data[i][j] = 0;
- }
- }
- }
- /*Конец вашего кода*/
- /*Памятка! Если вы стёрли строки доступные для редактирования - нажмите F5*/
- cout << endl;
- cout << "output array:";
- cout << endl;
- cout << "{";
- cout << endl;
- for (int i = 0; i < n; i++) {
- cout << "{";
- for (int j = 0; j < m; j++) {
- if (j > 0)
- cout << ", ";
- cout << data[i][j];
- }
- cout << "}";
- if (i != (n - 1))
- cout << ",";
- cout << endl;
- }
- cout << "}";
- delete[] data;
- system("pause");
- return 0;
- }
Add Comment
Please, Sign In to add comment