Strand Sort - 当我增加元素数量时,对数组进行排序不起作用

Strand Sort - Sorting the array doesn't work when I increase the number of elements

我正在尝试编写 St运行d 排序算法。它在排序 6-7 元素时有效。但是当我增加元素的数量时,它什么也没给出。知道这有什么问题吗?我该如何改进?


代码1

#include <stdio.h>

void fonk(int *, int *, int);

int main() {

    int a[] = {6, 9, 8, 10000, 9, 8, 9, 8}, 
        b[sizeof(a) / sizeof(int)], 
        c;

    fonk(a, b, sizeof(a) / sizeof(int));

    for (int k = 0; k < sizeof(a) / sizeof(int); k++) 
        printf("%d ",b[k]);

    return 0;
}

void fonk(int *ip, int *op, int indissayisi) { //sorting func

    if(indissayisi != 0) {
        int sub[indissayisi];

        int t = 1,
            missindice = 1,
            tyitutan,
            b = 0;
        sub[t - 1] = *ip;
        *ip = 0;

        for(int k = 1; k-1 < indissayisi; k++) { //getting sub list and changing indices of rest of *ip

            if(sub[t - 1] <= *(ip + k)) { //transfer ip to sub
                sub[t] = *(ip + k);
                t++;
                *(ip + k) = 0;
                missindice++;
            }
            else {
                *(ip + k - missindice) = *(ip + k); //change indice
            }
        }
        int t2 = t;
        tyitutan = indissayisi - t;
        if(*(op + indissayisi) == 0) { //transfering sub to op first time
            for(int l = 0; l < t; l++, t2--) {
                *(op + indissayisi - t2) = sub[l];
            }
        }
        else {
            for(int l = 0; l <  t; l++, t2--) { //transfering and sorting
                if(sub[l] < *(op + indissayisi + b)) {
                    *(op + indissayisi - t2) = sub[l];
                }
                else {
                    *(op + indissayisi - t2) = *(op + indissayisi + b);
                    b++;
                    l--;
                }
            }
        }
        fonk(ip, op, tyitutan);
    }
}

上面列表的输出

6 8 8 8 9 9 9 10000

输出 int a[] = {6, 9, 8, 10000, 9, 8, 9, 8, -5, 3, -80}

-5 3 6 8 8 8 9 9 9 10000 29930

1 运行 在 DevC++ tdm-gcc 4.9.2 64 位上。

调试:这一行

*(ip+k) = 0;
k == 8 时,

的索引超出了传递给函数 fonk 的数组 int a[] 的范围。允许的最大索引为 7.