-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSource.cpp
More file actions
115 lines (99 loc) · 2.31 KB
/
Source.cpp
File metadata and controls
115 lines (99 loc) · 2.31 KB
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#include <iostream>
#include <cmath>
using namespace std;
struct Coordinate
{
int x;
int y;
Coordinate(int x, int y)
{
this->x = x;
this->y = y;
}
};
int **getArray(Coordinate pos, int **numArr)
{
int **newArr = new int *[4];
pos.x = abs(pos.x);
pos.y = abs(pos.y);
int x = 10 - pos.x;
int y = 10 - pos.y;
*(newArr + 0) = new int[(pos.x * pos.y) + 1];
*(newArr + 1) = new int[(x * pos.y) + 1];
*(newArr + 2) = new int[(pos.x * y) + 1];
*(newArr + 3) = new int[(x * y) + 1];
int k = 0;
for (int i = 0; i < pos.y; i++)
{
for (int j = 0; j < pos.x; j++)
{
*(*(newArr + 0) + k++) = *(*(numArr + i) + j);
}
}
*(*(newArr + 0) + k++) = -1;
for (int i = 0; i < k; i++)
{
cout << *(*(newArr + 0) + i) << " ";
}
cout << endl;
k = 0;
for (int i = 0; i < pos.y; i++)
{
for (int j = pos.x; j < pos.x + x; j++)
{
*(*(newArr + 1) + k++) = *(*(numArr + i) + j);
}
}
*(*(newArr + 1) + k++) = -1;
for (int i = 0; i < k; i++)
{
cout << *(*(newArr + 1) + i) << " ";
}
cout << endl;
k = 0;
for (int i = pos.y; i < pos.y + y; i++)
{
for (int j = 0; j < pos.x; j++)
{
*(*(newArr + 2) + k++) = *(*(numArr + i) + j);
}
}
*(*(newArr + 2) + k++) = -1;
for (int i = 0; i < k; i++)
{
cout << *(*(newArr + 2) + i) << " ";
}
cout << endl;
k = 0;
for (int i = pos.y; i < pos.y + y; i++)
{
for (int j = pos.x; j < pos.x + x; j++)
{
*(*(newArr + 3) + k++) = *(*(numArr + i) + j);
}
}
*(*(newArr + 3) + k++) = -1;
for (int i = 0; i < k; i++)
{
cout << *(*(newArr + 3) + i) << " ";
}
cout << endl;
return newArr;
}
int main()
{
int **numArr = new int *[10];
for (int i = 0; i < 10; i++)
{
*(numArr + i) = new int[10];
}
for (int i = 0; i < 10; i++)
{
for (int j = 0; j < 10; j++)
{
*(*(numArr + i) + j) = i * j + j;
}
}
Coordinate position(-4, 2);
int **newArr = getArray(position, numArr);
}