功能:判断m是否为素数。
#include "stdio.h"
void wwjt();
int fun(int m)
{
/**********Program**********/
/********** End **********/
}
main()
{
int m,k=0;
for(m=100;m<200;m++)
if(fun(m))
{
printf("%4d",m);
k++;
if(k%5==0)
printf("\n");
}
printf("k=%d\n",k);
wwjt();
}
void wwjt()
{
FILE *IN,*OUT;
int iIN,iOUT,i;
IN=fopen("in.dat","r");
if(IN==NULL)
{
printf("Please Verify The Currernt Dir..It May Be Changed");
}
OUT=fopen("out.dat","w");
if(OUT==NULL)
{
printf("Please Verify The Current Dir.. It May Be Changed");
}
for(i=0;i<10;i++)
{
fscanf(IN,"%d",&iIN);
iOUT=fun(iIN);
fprintf(OUT,"%d\n",iOUT);
}
fclose(IN);
fclose(OUT);
}
登录后提交答案