-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
926 lines (773 loc) · 20.2 KB
/
main.cpp
File metadata and controls
926 lines (773 loc) · 20.2 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
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
#include<math.h>
#include<iostream>
#include<windows.h>
#include<stdio.h>
#include<conio.h>
#include<complex>
#include<math.h>
#include<vector>
#define PI 3.14159265
using namespace std;
template<typename T>
struct Points
{
private:
static double lambda;
public:
T x, y;
double& _lambda() { return lambda; }
template<typename V> friend std::ostream& operator <<(std::ostream&, const Points<V>&);
};
template<typename T>
double Points<T>::lambda = 0.000001;
template<typename T>
std::ostream& operator <<(std::ostream& os, const Points<T>& p)
{
return os << "(" << p.x << ", " << p.y << ")";
}
//Menu for selecting data type
void choose_type()
{
std::cout << "Choose the type of data you need:\n\n";
std::cout << "1. int\n";
std::cout << "2. float\n";
std::cout << "3. double\n";
std::cout << "4. std::complex<float>\n";
std::cout << "5. std::complex<double>\n";
std::cout << "\nEnter the number: ";
}
//Main menu
void menu()
{
std::cout << "1. Create a polyline\n";
std::cout << "2. Overwrite the vertex\n";
std::cout << "3. Output the vertex\n";
std::cout << "4. Get all vertices of the polyline\n";
std::cout << "5. Get the length of the polyline\n";
std::cout << "6. Add a vertex to the beginning of the polyline\n";
std::cout << "7. Add a vertex to the end of a certain polyline\n";
std::cout << "8. Create a polyline that is the 'sum' of two polylines\n";
std::cout << "9. ADDITIONAL QUESTION: Create a polyline regular polygon\n";
std::cout << "10. Compare broken lines\n";
std::cout << "11. Change precision\n";
std::cout << "12. Exit the program\n";
std::cout << "\nEnter the number: ";
}
//----------------------------------------------------------------
//Broken class declaration
template<typename T>
class Broken
{
private:
std::vector<Points<T>> data;
int n;
public:
Broken();
Broken(const int);
~Broken() = default;
Broken(const Broken<T>&) = default;
double len_broken() const;
double len_broken_complex() const;
Broken<T> operator +(const Broken<T>&) const;
Broken<T>& operator =(const Broken<T>&) = default;
void operator +=(const Points<T>&);
template<typename V> friend void operator +=(const Points<V>&, Broken<V>&);
template<typename V> friend std::ostream& operator <<(std::ostream&, const Broken<V>&);
bool operator ==(const Broken<T>&);
bool operator !=(const Broken<T>&);
Points<T>& operator [](int);
auto begin();
auto end();
int get_n() const;
};
template<typename T>
Broken<T>::Broken() :n(0) {}
template<typename T>
Broken<T>::Broken(const int n) : n(n)
{
data.resize(n);
}
template<typename T>
double Broken<T>::len_broken() const
{
std::vector<Points<T>> data_tmp = data;
double sum = 0;
for (int i = 0; i < n - 1; i++) {
if (i>=1 && data_tmp[i-1] == data_tmp[i+1]) continue;
double x = 0, y = 0;
x = pow(data_tmp[i].x - data_tmp[i + 1].x, 2);
y = pow(data_tmp[i].y - data_tmp[i + 1].y, 2);
sum += sqrt(x + y);
}
return sum;
}
template<typename T>
double Broken<T>::len_broken_complex() const
{
std::vector<Points<T>> data_tmp = data;
double sum = 0;
for (int i = 0; i < n - 1; i++) {
if (i>=1 && data_tmp[i-1] == data_tmp[i+1]) continue;
T z1, z2;
z1 = data_tmp[i].x - data_tmp[i + 1].x;
z2 = data_tmp[i].y - data_tmp[i + 1].y;
sum += sqrt(pow(std::abs(z1), 2) + pow(std::abs(z2), 2));
}
return sum;
}
template<typename T>
Broken<T> Broken<T>:: operator +(const Broken<T>& obj) const
{
Broken<T> tmp_obj(n + obj.n);
tmp_obj.n = n + obj.n;
int index = 0;
for (const auto& i : data) {
tmp_obj[index++] = i;
}
for (const auto& i : obj.data) {
tmp_obj[index++] = i;
}
return tmp_obj;
}
template<typename T>
void Broken<T>:: operator +=(const Points<T>& p)
{
data.push_back(p);
n++;
}
template<typename T>
void operator +=(const Points<T>& p, Broken<T>& obj)
{
std::vector<Points<T>> data_tmp(obj.n + 1);
int index = 1;
for (const auto& i : obj.data) data_tmp[index++] = i;
data_tmp[0] = p;
obj.data = data_tmp;
obj.n = obj.n++;
}
//Vertex Output Operator Overload
template<typename T>
std::ostream& operator <<(std::ostream& os, const Broken<T>& obj)
{
int index = 0;
for (auto& i: obj.data)
{
os << i;
if (index < obj.n - 1) os << " -> ";
index++;
}
return os;
}
template<typename T>
bool Broken<T>::operator !=(const Broken<T>& obj)
{
if (n != obj.n) throw "\n\nThe broken lines are incomparable, due to the different number of vertices.\n\n";
return !(*this == obj);
}
template<typename T>
bool Broken<T>::operator ==(const Broken<T>& obj)
{
if (n != obj.n) throw "\n\nThe broken lines are incomparable, due to the different number of vertices.\n\n";
int index = 0;
for (auto i : obj.data) if (data[index++] != i) return false;
return true;
}
template<typename T>
Points<T>& Broken<T>:: operator [](const int i)
{
//data.at(i);
if (i < n) return data[i];
else throw "Error! Attempt to access by case index.\n\n";
}
template<typename T>
auto Broken<T>::begin() { return data.begin(); }
template<typename T>
auto Broken<T>::end() { return data.end(); }
template<typename T>
int Broken<T>::get_n() const { return n; }
//----------------------------------------------------------
//Create a polyline
template<typename T>
void create_polyline(Broken<T>* mas_obj, int* count)
{
int n = 0;
do
{
std::cout << "How many vertices do you want to add now?: ";
std::cin >> n;
} while (n <= 0 || n != (int)n);
Broken<T> tmp(n);
for (auto& i : tmp) {
std::cout << "\nEnter x: ";
std::cin >> i.x;
std::cout << "Enter y: ";
std::cin >> i.y;
std::cout << "\n";
}
mas_obj[*count] = tmp;
*count += 1;
}
//Displaying polyline vertices
template<typename T>
void output_vertices(Broken<T>* mas_obj, int count)
{
int n = 0;
std::cout << "\n";
do
{
std::cout << "Which polyline vertices do you want to get?(counting from zero): ";
std::cin >> n;
} while (n < 0 || n!=(int)n || n >= count);
std::cout << "\nVertices: ";
std::cout << mas_obj[n];
std::cout << "\n\n";
system("pause");
}
//Getting the length of a polyline
template<typename T>
void len_poly(Broken<T>* mas_obj, int count)
{
int n = 0;
std::cout << "\n";
do
{
std::cout << "Which polyline length do you want to calculate?(counting from zero): ";
std::cin >> n;
} while (n < 0 || n >= count);
std::cout << "The length of the polyline is " << mas_obj[n].len_broken();
std::cout << "\n\n";
system("pause");
}
//Adding a vertex to the beginning of a polyline
template<typename T>
void ver_beg(Broken<T>* mas_obj, int count)
{
int n = 0;
Points<T> p;
std::cout << "\n";
do
{
std::cout << "In which polyline do I need to add a vertex to the beginning?(counting from zero): ";
std::cin >> n;
} while (n < 0 || n >= count);
std::cout << "\nEnter x: ";
std::cin >> p.x;
std::cout << "Enter y: ";
std::cin >> p.y;
p += mas_obj[n];
}
//Adding a vertex to the end of a polyline
template<typename T>
void ver_back(Broken<T>* mas_obj, int count)
{
int n = 0;
Points<T> p;
std::cout << "\n";
do
{
std::cout << "In which polyline do I need to add a vertex to the beginning?(counting from zero): ";
std::cin >> n;
} while (n < 0 || n >= count);
std::cout << "\nEnter x: ";
std::cin >> p.x;
std::cout << "Enter y: ";
std::cin >> p.y;
mas_obj[n] += p;
}
//Creating a new polyline obtained by joining two other polylines
template<typename T>
void sum_ver(Broken<T>* mas_obj, int* count)
{
int n = 0, m = 0;
std::cout << "\n";
do
{
std::cout << "Select the first vertex (counting from zero): ";
std::cin >> n;
} while (n < 0 || n >= *count);
do
{
std::cout << "Select the second vertex (counting from zero): ";
std::cin >> m;
} while (m < 0 || m >= *count);
mas_obj[*count] = mas_obj[n] + mas_obj[m];
*count += 1;
}
//Task
template<typename T>
void add_task(Broken<T>* mas_obj, int* count)
{
Points<T> p;
p.x = 0;
p.y = 0;
double a = 0;
double len = 0;
double angle = 0, result_x = 0, result_y = 0;
do {
std::cout << "\nEnter the number N - the number of vertices in the polyline (N>2): ";
std::cin >> a;
std::cout << "\nEnter the length of the polyline: ";
std::cin >> len;
} while (a <= 2);
angle = ((a - 2) * 180) / a;
mas_obj[*count] += p;
for (int i = 1; i < a; i++) {
result_x = (result_x + len * cos((i - 1) * ((180 - angle) * PI / 180)));
result_y = (result_y + len * sin((i - 1) * ((180 - angle) * PI / 180)));
p.x = result_x;
p.y = result_y;
mas_obj[*count] += p;
}
p.x = 0;
p.y = 0;
mas_obj[*count] += p;
*count += 1;
}
//Rewrites the vertex
template<typename T>
void rewrite_vertex(Broken<T>* mas_obj, int count)
{
int n = 0, m = 0;
std::cout << "\n";
do
{
std::cout << "Choose in which polyline the vertex should be rewritten?(counting from zero): ";
std::cin >> n;
} while (n < 0 || n >= count);
std::cout << "\n";
do
{
std::cout << "Choose which vertex you want to overwrite?(counting from zero): ";
std::cin >> m;
} while (m < 0 || m >= mas_obj[n].get_n());
std::cout << "\nEnter x: ";
std::cin >> mas_obj[n][m].x;
std::cout << "Enter y: ";
std::cin >> mas_obj[n][m].y;
}
//Displays the vertex of the polyline
template<typename T>
void input_vertex(Broken<T>* mas_obj, int count)
{
int n = 0, m = 0;
std::cout << "\n";
do
{
std::cout << "Choose from which polyline to display the vertex?(counting from zero): ";
std::cin >> n;
} while (n < 0 || n >= count);
std::cout << "\n";
do
{
std::cout << "Which vertex to display?(counting from zero): ";
std::cin >> m;
} while (m < 0 || m >= mas_obj[n].get_n());
std::cout << "\nVertex: " << mas_obj[n][m] << "\n\n";
system("pause");
}
template<typename T>
void compare_broken(Broken<T>* mas_obj, int count)
{
int n = 0, m = 0;
std::cout << "\n";
do
{
std::cout << "Select the first vertex (counting from zero): ";
std::cin >> n;
} while (n < 0 || n >= count);
do
{
std::cout << "Select the second vertex (counting from zero): ";
std::cin >> m;
} while (m < 0 || m >= count || m == n);
if (mas_obj[n] == mas_obj[m]) std::cout << "Broken lines are equal\n\n";
else std::cout << "Broken lines are not equal\n\n";
system("pause");
}
//---------------------------------------------------------
//Create a polyline (for std::complex<>)
template<typename S>
void create_polyline(Broken<std::complex<S>>* mas_obj, int* count)
{
int n = 0;
S num = 0;
do
{
std::cout << "How many vertices do you want to add now?: ";
std::cin >> n;
} while (n <= 0);
Broken<std::complex<S>> tmp(n);
for (auto& i:tmp)
{
std::cout << "\nEnter x: ";
std::cout << "\n\tEnter real: ";
std::cin >> num;
i.x.real(num);
std::cout << "\tEnter imag: ";
std::cin >> num;
i.x.imag(num);
std::cout << "\nEnter y: ";
std::cout << "\n\tEnter real: ";
std::cin >> num;
i.y.real(num);
std::cout << "\tEnter imag: ";
std::cin >> num;
i.y.imag(num);
}
mas_obj[*count] = tmp;
*count += 1;
}
//Rewrites the vertex(for std::complex<>)
template<typename S>
void rewrite_vertex(Broken<std::complex<S>>* mas_obj, int count)
{
int n = 0, m = 0;
S num = 0;
std::cout << "\n";
do
{
std::cout << "Choose in which polyline the vertex should be rewritten?(counting from zero): ";
std::cin >> n;
} while (n < 0 || n >= count);
std::cout << "\n";
do
{
std::cout << "Choose which vertex you want to overwrite?(counting from zero): ";
std::cin >> m;
} while (m < 0 || m >= mas_obj[n].get_n());
std::cout << "\nEnter x: ";
std::cout << "\n\tEnter real: ";
std::cin >> num;
mas_obj[n][m].x.real(num);
std::cout << "\tEnter imag: ";
std::cin >> num;
mas_obj[n][m].x.imag(num);
std::cout << "\nEnter y: ";
std::cout << "\n\tEnter real: ";
std::cin >> num;
mas_obj[n][m].y.real(num);
std::cout << "\tEnter imag: ";
std::cin >> num;
mas_obj[n][m].y.imag(num);
}
//Adding a vertex to the beginning of a polyline (for std::complex<>)
template<typename S>
void ver_beg(Broken<std::complex<S>>* mas_obj, int count)
{
int n = 0;
Points<std::complex<S>> p;
S num = 0;
std::cout << "\n";
do
{
std::cout << "In which polyline do I need to add a vertex to the beginning?(counting from zero): ";
std::cin >> n;
} while (n < 0 || n >= count);
std::cout << "\nEnter x: ";
std::cout << "\n\tEnter real: ";
std::cin >> num;
p.x.real(num);
std::cout << "\tEnter imag: ";
std::cin >> num;
p.x.imag(num);
std::cout << "\nEnter y: ";
std::cout << "\n\tEnter real: ";
std::cin >> num;
p.y.real(num);
std::cout << "\tEnter imag: ";
std::cin >> num;
p.y.imag(num);
p += mas_obj[n];
}
//Adding a vertex to the end of a polyline (for std::complex)
template<typename S>
void ver_back(Broken<std::complex<S>>* mas_obj, int count)
{
int n = 0;
Points<std::complex<S>> p;
S num = 0;
std::cout << "\n";
do
{
std::cout << "In which polyline do I need to add a vertex to the beginning?(counting from zero): ";
std::cin >> n;
} while (n < 0 || n >= count);
std::cout << "\nEnter x: ";
std::cout << "\n\tEnter real: ";
std::cin >> num;
p.x.real(num);
std::cout << "\tEnter imag: ";
std::cin >> num;
p.x.imag(num);
std::cout << "\nEnter y: ";
std::cout << "\n\tEnter real: ";
std::cin >> num;
p.y.real(num);
std::cout << "\tEnter imag: ";
std::cin >> num;
p.y.imag(num);
mas_obj[n] += p;
}
//Getting the length of a polyline(for std::complex<>)
template<typename S>
void len_poly(Broken<std::complex<S>>* mas_obj, int count)
{
int n = 0;
std::cout << "\n";
do
{
std::cout << "Which polyline length do you want to calculate?(counting from zero): ";
std::cin >> n;
} while (n < 0 || n >= count);
std::cout << "The length of the polyline is " << mas_obj[n].len_broken_complex();
std::cout << "\n\n";
system("pause");
}
///Ñîçäàòü ëîìàííóþ ïðàâèëüíûé ìíîãîóãîëüíèê (std::complex)
template<typename S>
void add_task(Broken<std::complex<S>>* mas_obj, int* count)
{
Points<std::complex<S>> p;
double a = 0;
double len = 0;
double angle = 0, result_x = 0, result_y = 0, abs = 0, tmp = 0;
do {
std::cout << "\nEnter the number N - the number of vertices in the polyline (N>2): ";
std::cin >> a;
std::cout << "\nEnter the length of the polyline: ";
std::cin >> len;
} while (a <= 2);
mas_obj[*count] += p;
angle = ((a - 2) * 180) / a;
for (int i = 1; i < a; i++) {
abs = len * cos((i - 1) * ((180 - angle) * PI / 180));
if (abs < 0) { tmp = sqrt(abs * abs / 2) * (-1); }
else { tmp = sqrt(abs * abs / 2); }
result_x = (result_x + tmp);
abs = len * sin((i - 1) * ((180 - angle) * PI / 180));
if (abs < 0) { tmp = sqrt(abs * abs / 2) * (-1); }
else { tmp = sqrt(abs * abs / 2); }
result_y = (result_y + tmp);
p.x.real(result_x); p.x.imag(result_x);
p.y.real(result_y); p.y.imag(result_y);
mas_obj[*count] += p;
}
p.x.real(0); p.x.imag(0);
p.y.real(0); p.y.imag(0);
mas_obj[*count] += p;
*count += 1;
}
//---------------------------------------------------------
//Precision change
template<typename T>
void change_precision()
{
Points<T> p;
double n = 0;
std::cout << "Now the accuracy is " << p._lambda();
std::cout << "\nEnter new precision: ";
std::cin >> n;
p._lambda() = n;
}
//Equality comparison operator
template<typename T>
bool operator==(Points<T>& p1, Points<T>& p2)
{
if (fabs(p1.x - p2.x) > p1._lambda()) return false;
if (fabs(p1.y - p2.y) > p1._lambda()) return false;
return true;
}
//Comparison operator for inequality
template<typename T>
bool operator!=(Points<T>& p1, Points<T>& p2)
{
if (fabs(p1.x - p2.x) < p1._lambda()) return false;
if (fabs(p1.y - p2.y) < p1._lambda()) return false;
return true;
}
//Equality comparison operator(for std::complex<>)
template<typename S>
bool operator==(Points<std::complex<S>>& p1, Points<std::complex<S>>& p2)
{
if (fabs(p1.x.real() - p2.x.real()) > p1._lambda()) return false;
if (fabs(p1.x.imag() - p2.x.imag()) > p1._lambda()) return false;
if (fabs(p1.y.real() - p2.y.real()) > p1._lambda()) return false;
if (fabs(p1.y.imag() - p2.y.imag()) > p1._lambda()) return false;
return true;
}
//Comparison operator for inequality(for std::complex<>)
template<typename S>
bool operator!=(Points<std::complex<S>>& p1, Points<std::complex<S>>& p2)
{
if (fabs(p1.x.real() - p2.x.real()) < p1._lambda()) return false;
if (fabs(p1.x.imag() - p2.x.imag()) < p1._lambda()) return false;
if (fabs(p1.y.real() - p2.y.real()) < p1._lambda()) return false;
if (fabs(p1.y.imag() - p2.y.imag()) < p1._lambda()) return false;
return true;
}
//Complex number output operator overload
template<typename S>
std::ostream& operator <<(std::ostream& os, const std::complex<S>& c)
{
return os << "(" << c.real() << ", " << c.imag() << ")";
}
//----------------------------------------------------------
//Main function
int main()
{
int n = 0;
int count = 0;
choose_type();
std::cin >> n;
if (n == 1)
{
Broken<int> mas_obj[20];
while (1)
{
try {
system("CLS");
menu();
std::cin >> n;
if (n == 1) create_polyline(mas_obj, &count);
if (n == 2) rewrite_vertex(mas_obj, count);
if (n == 3) input_vertex(mas_obj, count);
if (n == 4) output_vertices(mas_obj, count);
if (n == 5) len_poly(mas_obj, count);
if (n == 6) ver_beg(mas_obj, count);
if (n == 7) ver_back(mas_obj, count);
if (n == 8) sum_ver(mas_obj, &count);
if (n == 9) add_task(mas_obj, &count);
if (n == 10) compare_broken(mas_obj, count);
if (n == 11) change_precision<int>();
if (n == 12) break;
}
catch (const char* ex)
{
std::cout << ex;
system("pause");
system("CLS");
}
}
}
else if (n == 2)
{
Broken<float> mas_obj[20];
while (1)
{
try {
system("CLS");
menu();
std::cin >> n;
if (n == 1) create_polyline(mas_obj, &count);
if (n == 2) rewrite_vertex(mas_obj, count);
if (n == 3) input_vertex(mas_obj, count);
if (n == 4) output_vertices(mas_obj, count);
if (n == 5) len_poly(mas_obj, count);
if (n == 6) ver_beg(mas_obj, count);
if (n == 7) ver_back(mas_obj, count);
if (n == 8) sum_ver(mas_obj, &count);
if (n == 9) add_task(mas_obj, &count);
if (n == 10) compare_broken(mas_obj, count);
if (n == 11) change_precision<float>();
if (n == 12) break;
}
catch (const char* ex)
{
std::cout << ex;
system("pause");
system("CLS");
}
}
}
else if (n == 3)
{
Broken<double> mas_obj[20];
while (1)
{
try {
system("CLS");
menu();
std::cin >> n;
if (n == 1) create_polyline(mas_obj, &count);
if (n == 2) rewrite_vertex(mas_obj, count);
if (n == 3) input_vertex(mas_obj, count);
if (n == 4) output_vertices(mas_obj, count);
if (n == 5) len_poly(mas_obj, count);
if (n == 6) ver_beg(mas_obj, count);
if (n == 7) ver_back(mas_obj, count);
if (n == 8) sum_ver(mas_obj, &count);
if (n == 9) add_task(mas_obj, &count);
if (n == 10) compare_broken(mas_obj, count);
if (n == 11) change_precision<double>();
if (n == 12) break;
}
catch (const char* ex)
{
std::cout << ex;
system("pause");
system("CLS");
}
}
}
else if (n == 4)
{
Broken<std::complex<float>> mas_obj[20];
while (1)
{
try {
system("CLS");
menu();
std::cin >> n;
if (n == 1) create_polyline(mas_obj, &count);
if (n == 2) rewrite_vertex(mas_obj, count);
if (n == 3) input_vertex(mas_obj, count);
if (n == 4) output_vertices(mas_obj, count);
if (n == 5) len_poly(mas_obj, count);
if (n == 6) ver_beg(mas_obj, count);
if (n == 7) ver_back(mas_obj, count);
if (n == 8) sum_ver(mas_obj, &count);
if (n == 9) add_task(mas_obj, &count);
if (n == 10) compare_broken(mas_obj, count);
if (n == 11) change_precision<std::complex<float>>();
if (n == 12) break;
}
catch (const char* ex)
{
std::cout << ex;
system("pause");
system("CLS");
}
}
}
else if (n == 5)
{
Broken<std::complex<double>> mas_obj[20];
while (1)
{
try {
system("CLS");
menu();
std::cin >> n;
if (n == 1) create_polyline(mas_obj, &count);
if (n == 2) rewrite_vertex(mas_obj, count);
if (n == 3) input_vertex(mas_obj, count);
if (n == 4) output_vertices(mas_obj, count);
if (n == 5) len_poly(mas_obj, count);
if (n == 6) ver_beg(mas_obj, count);
if (n == 7) ver_back(mas_obj, count);
if (n == 8) sum_ver(mas_obj, &count);
if (n == 9) add_task(mas_obj, &count);
if (n == 10) compare_broken(mas_obj, count);
if (n == 11) change_precision<std::complex<double>>();
if (n == 12) break;
}
catch (const char* ex)
{
std::cout << ex;
system("pause");
system("CLS");
}
}
}
else std::cout << "\n\nPlease enter the correct number next time.\n\n";
}