-
Notifications
You must be signed in to change notification settings - Fork 0
/
kolekcijos.cpp
74 lines (61 loc) · 1.43 KB
/
kolekcijos.cpp
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
#include <iostream>
#include <fstream>
using namespace std;
void rikiuoti(int n, int* mas) {
for (int i = 0; i < n; i++) {
for (int j = i + 1; j < n; j++) {
if (mas[i] > mas[j]) {
int temp = mas[i];
mas[i] = mas[j];
mas[j] = temp;
}
}
}
}
void iterptiSkaiciu(int& n, int* seka, int sk) {
seka[n] = sk;
n++;
rikiuoti(n, seka);
}
void naikintiIndeksa(int& n, int* seka, int skI) {
for (int i = skI; i < n; i++) {
seka[i] = seka[i + 1];
}
n--;
}
void dovanoti(int& nIs, int* mIs, int& nI, int* mI, int k) {
for (int i = 0; i < nIs; i++) {
if (mIs[i] / k > 0) {
iterptiSkaiciu(nI, mI, mIs[i]);
naikintiIndeksa(nIs, mIs, i);
i--;
}
}
}
void nuskaityti(char* failas, int& n, int* seka) {
ifstream fIn(failas);
fIn>>n;
for (int i = 0; i < n; i++) {
fIn >> seka[i];
}
fIn.close();
}
void isvestiMasyva(int n, int* m) {
for (int i = 0; i < n; i++) {
cout << m[i] << " ";
}
cout << endl;
}
int main()
{
int n1, m1[100], n2, m2[100];
nuskaityti("in1.txt", n1, m1);
nuskaityti("in2.txt", n2, m2);
dovanoti(n2, m2, n1, m1, 10);
dovanoti(n1, m1, n2, m2, 100);
cout << "Rasos kolekcija: " << endl;
isvestiMasyva(n1, m1);
cout << "Rimo kolekcija: " << endl;
isvestiMasyva(n2, m2);
return 0;
}