Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<conio.h>
- using namespace std;
- int main()
- {
- cout<<"\t\t \tUTS: Selection Sort Descending"<<endl;
- cout<<"\ndata :\n 5, 2, 21, 4, 9, 16, 13, 3"<<endl<<endl;
- int i,j,Imaks,maks,temp;
- int L[10]={5, 2, 21, 4, 9, 16, 13, 3};
- for (i=9;i>=1;i--)
- {
- Imaks=0;
- maks=L[0];
- for (j=1;j<=i;j++)
- {
- if (L[j]<maks)
- {
- Imaks=j;
- maks=L[j];
- }
- }
- temp=L[i];
- L[i]=maks;
- L[Imaks]=temp;
- }
- cout<<"data terurut descending :"<<endl;
- for (i=0;i<=9;i++)
- {
- cout<<L[i]<<" ";
- }
- cout<<endl;
- getch();
- }
Add Comment
Please, Sign In to add comment