Advertisement
Guest User

Untitled

a guest
Sep 17th, 2019
101
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.  
  3. /* run this program using the console pauser or add your own getch, system("pause") or input loop */
  4.  
  5. using namespace std;
  6.  
  7. int main(int argc, char** argv) {
  8. /*int n;
  9. cin>>n;
  10. int T[n];
  11. for(int i =0;i<n;i++)
  12. {
  13. cin>>T[i];
  14. }*/
  15.  
  16. string T = "napis";
  17. int n = T.size();
  18.  
  19. int i=1;
  20. while(i<n)
  21. {
  22. int pom=T[i];
  23. int k=i-1;
  24. while(k>=0 && T[k]>pom)
  25. {
  26. T[k+1]=T[k];
  27. k--;
  28. }
  29.  
  30. T[k+1]=pom;
  31. i++;
  32. }
  33.  
  34. for(int i=0;i<n;i++)
  35. {
  36. cout<<T[i];
  37. }
  38.  
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement