[此贴子已经被作者于2005-10-9 1:08:34编辑过]
#include<conio.h> #include<stdio.h>
int isP(int m) { int i; for(i=2;i<m;i++) if(m%i==0)return 0; return 1; } void num(int m,int k,int xx[]) { int i,j;int *p=xx; for(i=m+1,j=0;;i++) { if(isP(i)){*p=i;j++;p++;} if(j==k)break; } } void readwriteDAT() { int m,n,xx[1000],i; FILE *rf,*wf; rf=fopen("in.dat","r"); wf=fopen("out.dat","w"); for(i=0;i<10;i++) { fscanf(rf,"%d,%d",&m,&n); num(m,n,xx); for(m=0;m<n;m++)fprintf(wf,"%d",xx[m]); fprintf(wf,"\n"); } fclose(rf); fclose(wf); }
main() { int m,n,xx[1000]; clrscr(); printf("\nPlease enter two integers:"); scanf("%d,%d",&m,&n); num(m,n,xx); for(m=0;m<n;m++) printf("%d ",xx[m]); printf("\n"); readwriteDAT(); } 不知道怎么回事,就是写不进去,readwriteDAT();函数好像没有用,郁闷!
[此贴子已经被作者于2005-10-9 3:36:00编辑过]