access violation该怎么控制?
最近编程时总会遇到access violation的错误#define M 7
#include < stdio.h >
void main()
{
int a[40];
int k = 0;
for (int i = 0; i < M; i++)
{
for (int j = 0; j <= 2*i; j++)
{
a[k++] = i*2+1;
}
}
for (i = 0; i < 40; i++)
{
printf("%d,", a[i]);
}
}
原题是要求数列1,3,3,3,5,5,5,5,5,7,7,7,7,7,7,7的前40项
这该要如何控制?