Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Talltabell {
- private int[] tabell = {5, 3, 7};
- public static int[] shellsort(int[] t) {
- int s = t.length / 2;
- while (s > 0) {
- for (int i = s; i < t.length; ++i) {
- int j = i, flytt = t[i];
- while(j >= s && flytt < t[j-s]) {
- t[j] = t[j - s];
- j -= s;
- }
- t[j] = flytt;
- }
- s = (s==2) ? 1 : (int)(s / 2.2);
- }
- return t;
- }
- public static void main(String[] args) {
- Talltabell t = new Talltabell();
- for (int i = 0; i < t.tabell.length; i++) {
- System.out.println(t.shellsort(t.tabell)[i]);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement