我有一些用于时间排序算法的代码(用于学校),但每当数组大小大于 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)