在以下源代码中,最大数组长度为500000。运行起来没有问题,但是当我将长度设置为600000时,没有输出。谁能解释为什么会这样?
#include<stdio.h>
#include<math.h>
#include<time.h>
void insertion_sort(int [], int );
int main()
{
int a[600000],i,n;
clock_t s,e;
double d;
printf("Enter the amount of data: ");
scanf("%d",&n);
for(i = 0;i < n; i++)
{
a[i]=rand();
}
s = clock();
insertion_sort(a,n);
e = clock();
d = ((double)(e-s))/CLOCKS_PER_SEC;
printf("Execution time: %f",d);
}
void insertion_sort(int a[], int n)
{
int i,j,key;
for(j = 1;j < n; j++)
{
key = a[j];
i = j-1;
while(i>=0 && a[i]>key)
{
a[i+1] = a[i];
i--;
}
a[i+1] = key;
}
}
应该有一些输入过程,但是输出返回如下:
返回的过程-1073741571(0xC00000FD)执行时间:2.491 s 按任意键继续。