Run Code
|
API
|
Code Wall
|
Users
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
selection sort
//clang 3.8.0 #include <iostream> void selectionSort(int *nums,int size){ for(int i=0;i<size;++i ){ int min_index=i; for(int y=i+1;y<size;++y ){ if(nums[min_index]>nums[y]){ min_index=y; } } std::swap(nums[min_index],nums[i]); } } void printArray(int *nums,int size){ for(int i=0;i<size;++i ) std::cout<<nums[i]<<" "; } int main() { int nums[]={9,8,7,4,3,6}; int size=sizeof(nums)/sizeof(nums[0]); selectionSort(nums,size); printArray(nums,size); }
run
|
edit
|
history
|
help
0
Please
log in
to post a comment.
Specialization on signed types
Clang-IsBaseOf
Program to Time Difference
Compute Power Manually
NaN inside set
nontype template parameter produced with decltype for function
Member inheritance
Crow unordered_map Quiz
DESim Example Starter Code
MPL 2-0
Please log in to post a comment.