#include <stdio.h>
void fun( int m, int *k, int xx[] )
{
int i,j,n=0;
for(i=4;i<m;i++)
{
for(j=2;j<m;j++)
while(i>j)
{
if(i%j==0)
xx[n++]=i;
}
}
*k=n;
}
main()
{
int m, n, zz[100];
void NONO ( );
printf( "\nPlease enter an integer number between 10 and 100: " );
scanf( "%d", &n );
fun( n, &m, zz );
printf( "\n\nThere are %d non-prime numbers less than %d:", m, n );
for( n = 0; n < m; n++ )
printf( "\n %4d", zz[n] );
NONO();
}
void NONO()
{
/* 请在此函数内打开文件,输入测试数据,调用 fun 函数,
输出数据,关闭文件。 */
int m, n, zz[100];
FILE *rf, *wf ;
rf = fopen("in.dat","r") ;
wf = fopen("out.dat","w") ;
fscanf( rf, "%d", &n );
fun( n, &m, zz );
fprintf(wf, "%d\n%d\n", m, n );
for( n = 0; n < m; n++ )
fprintf(wf, "%d\n", zz[n] );
fclose(rf) ;
fclose(wf) ;
}
fun函数中一用while就出现unhandled exception in prog1.exe:0xC0000005:Access VIOLATION,快崩溃了,求高人帮忙
……求问我到底错哪了……