Advertisement
rattin99

Untitled

Oct 22nd, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. #include<iostream>
  2. using namespace std;
  3.  
  4.  
  5. void selsort (int inp[],int n)
  6. {
  7. for(int i = 0;i<n; i++)
  8. {
  9. int indexsmall = i;
  10. for(int j = i+1;j<n;j++)
  11. {
  12. if(inp[j]< inp[indexsmall])
  13. {
  14. indexsmall = j;
  15. }
  16. }
  17. //swap
  18. int temp = inp[i];
  19. inp[i] = inp[indexsmall];
  20. inp[indexsmall] = temp;
  21. }
  22. }
  23.  
  24. int main ()
  25. {
  26. int arr[5];
  27. for(int a=0;a<6; a++)
  28. {
  29. cin >> arr[a];
  30. }
  31. selsort(arr,5);
  32. for(int a=0;a<6; a++)
  33. {
  34. cout << arr[a];
  35. }
  36.  
  37.  
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement