小编you*_*dad的帖子

时间排序算法的程序不断崩溃

我有一些用于时间排序算法的代码(用于学校),但每当数组大小大于 20k 时,它就会不断崩溃。

这是我的主要文件:

#include <stdio.h>
#include <stdlib.h>
#include <time.h>

#include "sorting.h"

#define ARG_COUNT 1

int main(int argc, char *argv[]) {
    
    if (argc != ARG_COUNT + 1) {
        printf("Too few or too many arguments passed.\n");
        exit(1);
    }

    if (atoi(argv[1]) < 10000) {
        printf("Array lenght should be at least 10 000.");
        exit(2);
    }

    int arr_lenght = atoi(argv[1]);
    srand(time(0));

    int *arr1 = (int *)calloc(arr_lenght, arr_lenght * sizeof(int));
    for (int i = 0; i < arr_lenght; i++) {
        arr1[i] = rand() % 20; …
Run Code Online (Sandbox Code Playgroud)

c sorting timing clock time.h

1
推荐指数
1
解决办法
67
查看次数

标签 统计

c ×1

clock ×1

sorting ×1

time.h ×1

timing ×1