Advertisement
Guest User

Untitled

a guest
Jan 17th, 2019
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. void wyswietl (double T[], int n ){
  4. for (int i=0;i<n;i++) cout<<T[i]<<"\t";
  5. cout<<endl;
  6. }
  7. void sortuj (double T[], int n){
  8. double pom;
  9. int k;
  10. for (int i=1;i<n;i++){
  11. pom = T[i];
  12. k = i-1;
  13. for (k; k>=0&&T[k]>pom; k--){
  14. T[k+1]=T[k];
  15. }
  16. T[k+1] = pom;
  17. }
  18. }
  19. main(){
  20. double T[8] = {7,2,1,3,4,6,5,8};
  21. int n =8;
  22. cout<<"Przed sortowaniem:\t";
  23. wyswietl(T,n);
  24. sortuj(T,n);
  25. cout<<"Po sortowaniu:\t";
  26. wyswietl(T,n);
  27. return 0;
  28. system("pause");
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement