iseqai

Untitled

Sep 24th, 2020
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.52 KB | None | 0 0
  1. #include<iostream>
  2. #include<conio.h>
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. cout<<"\t\t \tUTS: Selection Sort Descending"<<endl;
  8. cout<<"\ndata :\n 5, 2, 21, 4, 9, 16, 13, 3"<<endl<<endl;
  9.  
  10. int i,j,Imaks,maks,temp;
  11.  
  12. int L[10]={5, 2, 21, 4, 9, 16, 13, 3};
  13.  
  14. for (i=9;i>=1;i--)
  15. {
  16. Imaks=0;
  17. maks=L[0];
  18. for (j=1;j<=i;j++)
  19. {
  20. if (L[j]<maks)
  21. {
  22. Imaks=j;
  23. maks=L[j];
  24. }
  25. }
  26. temp=L[i];
  27. L[i]=maks;
  28. L[Imaks]=temp;
  29. }
  30. cout<<"data terurut descending :"<<endl;
  31. for (i=0;i<=9;i++)
  32. {
  33. cout<<L[i]<<" ";
  34. }
  35. cout<<endl;
  36. getch();
  37. }  
Add Comment
Please, Sign In to add comment