Advertisement
Guest User

Untitled

a guest
Sep 2nd, 2015
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. public class Talltabell {
  2.  
  3. private int[] tabell = {5, 3, 7};
  4.  
  5. public static int[] shellsort(int[] t) {
  6. int s = t.length / 2;
  7. while (s > 0) {
  8. for (int i = s; i < t.length; ++i) {
  9. int j = i, flytt = t[i];
  10. while(j >= s && flytt < t[j-s]) {
  11. t[j] = t[j - s];
  12. j -= s;
  13. }
  14. t[j] = flytt;
  15. }
  16. s = (s==2) ? 1 : (int)(s / 2.2);
  17. }
  18. return t;
  19. }
  20.  
  21. public static void main(String[] args) {
  22. Talltabell t = new Talltabell();
  23. for (int i = 0; i < t.tabell.length; i++) {
  24. System.out.println(t.shellsort(t.tabell)[i]);
  25. }
  26. }
  27.  
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement