Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- using namespace std;
- void selsort (int inp[],int n)
- {
- for(int i = 0;i<n; i++)
- {
- int indexsmall = i;
- for(int j = i+1;j<n;j++)
- {
- if(inp[j]< inp[indexsmall])
- {
- indexsmall = j;
- }
- }
- //swap
- int temp = inp[i];
- inp[i] = inp[indexsmall];
- inp[indexsmall] = temp;
- }
- }
- int main ()
- {
- int arr[5];
- for(int a=0;a<6; a++)
- {
- cin >> arr[a];
- }
- selsort(arr,5);
- for(int a=0;a<6; a++)
- {
- cout << arr[a];
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement