Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int selection_sort(int table[], int x)
- {
- for(int j=0;j<x-1;j++)
- {
- int mini = j;
- for(int i=j+1;i<x;i++)
- {
- if(table[i]<table[mini])
- {
- mini = i;
- }
- }
- if(mini != j)
- {
- int pom=table[mini];
- table[mini]=table[j];
- table[j]=pom;
- for(int y=0;y<x;y++)
- {
- cout<<table[y]<<" ";
- }
- cout<<endl;
- }
- }
- }
- int main() {
- int table[] = {-10, 16, 5, 6};
- selection_sort(table, 4); }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement