-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSource.cpp
More file actions
43 lines (43 loc) · 921 Bytes
/
Copy pathSource.cpp
File metadata and controls
43 lines (43 loc) · 921 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include <iostream>
#include <stdio.h>
#include <iomanip>
using namespace std;
void func(int** arr, int n)
{
for (int i = 0; i < n; i++)
{
for (int j = 0; j < n; j++)
{
arr[j][i] = 1;
}
for (int j = i + 1; j < n - i - 1; j++) {
arr[j][i] = 0;
}
}
for (int i = 0; i < n; i++)
{
for (int j = 0; j < n; j++)
cout << setw(4) << arr[i][j];
cout << endl;
}
}
int main()
{
setlocale(LC_ALL, "Ukr");
int** arr, n;
cout << "Âåäiòü ðîçìið ìàòðèöi: ";
cin >> n;
cout << "-----------------------------------------------------" << endl;
arr = new int* [n];
for (int i = 0; i < n; i++)
{
arr[i] = new int[n];
}
func(arr, n);
for (int i = 0; i < n; i++)
{
delete[] arr[i];
}
delete[] arr;
return 0;
}