-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSource.cpp
More file actions
51 lines (43 loc) · 961 Bytes
/
Copy pathSource.cpp
File metadata and controls
51 lines (43 loc) · 961 Bytes
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
#include <iostream>
#include <vector>
using namespace std;
void Swap(int* a, int* b)
{
int temp = *a;
*a = *b;
*b = temp;
}
void BubbleSort(vector<int>& vargu)
{
cout << "Elementet ne varg: " << vargu.size() << endl;
for (int i = 0; i < vargu.size(); i++)
{
for (int j = 0; j < vargu.size() - 1; j++)
{
if (vargu[j] > vargu[j + 1])
Swap(&vargu[j], &vargu[j + 1]);
}
}
}
void PrintoVargun(vector<int> vargu)
{
for (int i = 0; i < vargu.size(); i++)
cout << vargu[i] << " ";
cout << endl;
}
int main()
{
cout << "Shtyp numrat (-1 per nderprerje):\n";
vector<int> vargu;
int num = 0;
while (num != -1)
{
cin >> num;
if (num != -1)
vargu.push_back(num);
}
BubbleSort(vargu);
cout << "Vargu i sortuar eshte:\n";
PrintoVargun(vargu);
return 0;
}