简单的数组问题,不知道为什么编译不对
简单的冒泡法排序,不知道为啥在vs2017上编译出错 显示 Run-Time Check Failure #2 - Stack around the variable a was corrupted多谢指教!
#include<stdio.h>
int main()
{
int i,j,t=0;
int a[] = { 1,3,6,2,5 };
for (i = 1;i <= 4;i++) {
for (j = 1;j <= 5 - i;j++)
if (a[j] > a[j+1]) {
t = a[j+1];
a[j+1] = a[j];
a[j] = t;
}
}
printf("\n");
for (i = 0;i < 5;i++) {
printf("%d", a[i]);
}
return 0;
}