-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdmanalll.cpp
More file actions
291 lines (148 loc) · 3.81 KB
/
dmanalll.cpp
File metadata and controls
291 lines (148 loc) · 3.81 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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
#pragma once
#include "dmanalll.h"
#include <iostream>
dmanall::dmanall()
{
std::cout << " enter the array size for a int type \n";
std::cin >> a;// how to use pointer in member funcitions to create dynamic ;
fir = new int[a];
for (int d = 0; d < a; d++)
{
*(fir + d) = d;
}
for (int d = 0; d < a; d++)
{
std::cout << *(fir + d) << "\n";
}
}
void dmanall::add() {
int d;
std::cin >> d;
*(fir + cur) = d;
++cur;
//i was intial going to have the user have the ability to add ahead of the cur but i realize
//i wouldnt be able to control data being overwritten in this regard maybe later when i get gui .
// maybe like excel or gui databases
}
void dmanall :: storedvalue()
{
for (int d = 0; d < a; d++)
{
std::cout << *(fir+d) << std::endl;
}
}
void dmanall :: delmem()
{
delete []fir;
fir = nullptr;
}
void dmanall::size()
{
//check for size of array
std::cout << " the size of the array currently is " << a <<std::endl;
}
void dmanall::scaleup()
{
int con = 1;
while (con == 1)
{
std::cout << " Enter the value you like to resize too \n ";
std::cin >> b;
if (b <= a)
{
std::cout << "use the scaledown function to delete and resize down \n";
}
else if (b > a)
{
temp = new int[b];
for (int c = 0; c < a; c++)
{
(*(temp + c)) = (*(fir + c));
}
//possibly use a pointer to alway point to the current array required.
// tried method with just using the fir point to point to new pointer when called .
for (int c = 0; c < a; c++)
{
std::cout << "this is temp array \n" << c<<" " << *(temp + c) << std::endl;
}
for (int c = a; c < b; c++)
{
*(temp + c) = c;
}
for (int c = 0; c < b; c++)
{
std::cout <<"temp array " << c << " " << *(temp + c) << std::endl;
}
delete[] fir;
// i had a
fir = new int[b];
for (int d = 0; d < b; d++)
{
*(fir + d) = *(temp + d);
std::cout << " the new fir array " << *(fir + d) << std::endl;
}
delete[] temp;
temp = nullptr;
a = b;
con = 0;
}
}
}
void dmanall::scaledown()
{
int con = 1;
while (con == 1)
{
int choice;
std::cout << " which element of the array would you like to delete 0 is the first element " << "\n";
size();
std::cin >> choice;
std::cout << std::endl;
std::cout << "this is the element you have chosen and it value " << choice << " " << *(fir + choice) << "is this correct 1 for yes ,0 for no, or 2 to cancel \n";
int yesorno;
std::cin >> yesorno;
if (yesorno == 1)
{
if (choice == (a-1))
{
}
else if (choice < a)
{
for (int d = choice; d < (a-1); d++)
{
*(fir + d) = *(fir + (d + 1));
}
}
else
{
std::cout << "trying the crash the program ey. \n now deleting system 32 and replacing all your files with nsfw videos JK becareful what you type you could cause a leak :)" << std::endl;
}
temp = new int[a - 1];
for (int d = 0; d < (a - 1); d++)
{
*(temp + d) = *(fir + d);
std::cout << *(temp + d) << std::endl;
}
delete[] fir;
fir = nullptr;
a--;
fir = new int[a];
for (int d = 0; d < a; d++)
{
*(fir + d) = *(temp + d);
std::cout << "fir array after downscale \n " << *(fir + d) << std::endl;
}
delete[] temp;
temp = nullptr;
}
else if (yesorno == 0)
{
std::cout << "please try again " << std::endl;
}
else if (yesorno == 2)
{
con = 0;
}
con = 0;
}
}