0 / 0 / 0
Регистрация: 14.07.2019
Сообщений: 16
|
|
1
|
Доброго времени! Нужно передать динамический массив из функции
20.10.2019, 12:13. Показов 477. Ответов 0
C++ | 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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
| void read(int count_math, double*** cord,int* n,int* m)
{
char temp;
count_math = 1;
ifstream in("input.txt");
if (in.is_open())
{
while (!in.eof())
{
in >> temp;
if (temp == '$') count_math++;
}
in.clear();
in.close();
////////
m = new int[count_math];
for (int i = 0; i < count_math; i++) m[i] = 3;
///////
///////////////////////////////////////////////////
/////////
int count = 0;
int* count_spase;
count_spase = new int[count_math];
int k = 0;
/////////
ifstream in("input.txt");
in.is_open();
while (!in.eof())
{
in.get(temp);
if (temp != '$' && temp == '\n') count++;
else if (temp == '$')
{
if (temp == 'eof')
{
count_spase[k] = (count + 1) * m[k];
count = 0;
in.get(temp);
}
else
{
count_spase[k] = count * m[k];
count = 0;
in.get(temp);
}
k++;
}
}
in.clear();
count_spase[k] = (count + 1) * m[k];
///////
n = new int[count_math];
for (int i = 0; i < count_math; i++)
{
n[i] = (count_spase[i] / m[i]);
}
//////
/////////////////////////////////////////////////////////////////////////////
//////
cord = new double** [count_math];
for (int k = 0; k < count_math; k++) cord[k] = new double* [n[k]];
for (int k = 0; k < count_math; k++)
for (int i = 0; i < n[k]; i++) cord[k][i] = new double[m[k]];
//////
///////
int i = 0;
int j = 0;
k = 0;
ifstream into("input.txt");
in.is_open();
for (int k = 0; k < count_math; k++)
{
for (int i = 0; i < n[k]; i++)
{
for (int j = 0; j < m[k]; j++)
{
into >> cord[k][i][j];
}
}
into >> temp;
}
into.clear();
into.close();
}
else
{
cout << "error";
}
}
void matrix()
{
int count_math = 1;
bool counter = false;
double*** cord;
double*** cord_push;
int* n;
int* m;
read(count_math, cord,n,m);
cord_push = new double** [count_math];
for (int p = 0; p < count_math; p++)
{
cord_push[p] = new double* [n[p]];
}
for (int p = 0; p < count_math; p++)
for (int i = 0; i < n[p]; i++)
cord_push[p][i] = new double[m[p]];
for (int p = 0; p < count_math; p++)
{
for (int i = 0; i < n[p]; i++)
{
for (int j = 0; j < m[p]; j++)
{
cord_push[p][i][j] = 0;
for (int k = 0; k < 3; k++)
{
cord_push[p][i][j] = cord[p][i][k] * ar[k][j];
}
}
}
}
for (int p = 0; p < count_math;p++)
{
for (int i = 0; i < n[p]; i++)
{
MoveToEx(hDC, cord_push[p][i][0], cord_push[p][i][1], NULL);
LineTo(hDC, cord_push[p][i][0], cord_push[p][i][1]);
}
}
} |
|
0
|