-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprogram.cpp
More file actions
43 lines (31 loc) · 689 Bytes
/
program.cpp
File metadata and controls
43 lines (31 loc) · 689 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
#include <iostream>
#include <vector>
int swp;
using namespace std;
void selectionSort(vector<int>& arr)
{
int n = arr.size();
for (int i = 0; i < n - 1; i++)
{
int minIndex = i;
for (int j = i + 1; j < n; j++)
{
if (arr[j] < arr[minIndex])
{
minIndex = j;
}
}
swap(arr[i], arr[minIndex]);
}
}
int main() {
int a;
vector<int> exampleVector;
// Keep reading integers until a non-integer is encountered
while (cin >> a) {
exampleVector.push_back(a);
}
selectionSort(exampleVector);
cout << exampleVector.size();
return 0;
}