MCPcopy Create free account
hub / github.com/codemistic/Data-Structures-and-Algorithms / main

Function main

CPP/questions/SelectionSort.cpp:9–36  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7// it is slow sorting algorithm
8using namespace std;
9int main()
10{
11 vector<int>v;
12 int n;
13 cout<<"Enter size of array/vector\n";
14 cin>>n;
15 for(int i=0;i<n;i++)
16 {
17 int temp;
18 cin>>temp;
19 v.push_back(temp);
20 }
21 // Selection sort
22 for(int i=0;i<n;i++)
23 {
24 int sml=i;
25 for(int j=i+1;j<n;j++)
26 {
27 if(v[j]<v[sml])
28 {
29 sml=j;
30 }
31 }
32 int temp=v[i];
33 v[i]=v[sml];
34 v[sml]=temp;
35 }
36}

Callers

nothing calls this directly

Calls 1

push_backMethod · 0.80

Tested by

no test coverage detected