1、 题目1:下列程序的功能是:将大于整数m且紧靠m的k个素数存入数组xx。请编写函数num(int m,int k,int xx)实现函数的要求 ,最后调用函数readwriteDAT()把结果输出到文件out.dat中。例如:若输入17,5,则应输出:19,23,29,31,37。注意:部分源程序已给出。请勿改动主函数main()和函数readwriteDAT()的内容。-类型:素数。void num(int m,int k,int xx) /*标准答案*/int data=m+1;int half,n=0,I; while(1) half=data/2;for(I=2;Ihalf)xxn=d
2、ata;n+;if(n=k)break;data+; 或者:void num(int m,int k,int xx)int i,j,s=0;for(i=m+1;k0;i+)for(j=2;j0;m+)if(isP(m) xx=m;k-; #include #include void readwriteDAT() ;int isP(int m) int i ;for(i = 2 ; i #define MAX 200int aMAX, bMAX, cnt = 0;void jsVal()void readDat() int i ;FILE *fp ;fp = fopen(“in.dat“, “r
3、“) ;for(i = 0 ; i =index;j-)ch=xxstrl-1;for(k=strl-1;k0;k-)xxk=xxk-1;xx0=ch;或者:void StrOR(void) int i;char a80,*p;for(i=0;i=0;j-)if(xxj=o) righto=j;break; for(j=righto+1;j=xx) p1-;memcpy(t1,p1+1,p2-p1);t1p2-p1=0;strcat(t,t1);strcat(t,“ “);if(p1=Aj=0;j-)ppj+1=ppj; pp0=xxl; k+;I-; strcat(ch,pp);strcpy
4、(pp, “);k=1;if(I=-1)break;while(xxlz)j=0;j-)ppj+1=ppj; pp0=xxl; k+; I-;strcat(ch,pp); strcpy(pp,“);k=0;if(I=-1)break;strcpy(xxl,ch);或者:void StrOL(void) int i,j,k,m,n,ll;char yy80;for(i=0; i =0; j-) if(isalpha(xxj) k+;else for(m=1; maaj%1000)data=aa;aa=aaj;aaj=data;else if(aa%1000=aaj%1000)if(aa#incl
5、ude#includeint aa200,bb10;void jsSort()void main()readDat();jsSort();writeDat();system(“pause“);readDat()FILE *in;int i;in=fopen(“in.dat“,“r“);for(i=0; i200; i+) fscanf(in,“%d,“,fclose(in);writeDat()FILE *out;int i;clrscr();out=fopen(“out.dat“,“w“);for(i=0; i10; i+)printf(“i=%d,%dn“,i+1,bb);fprintf(
6、out,“%dn“,bb);fclose(out);IN.DAT6012509990127025808870555334760781456012509990127025808870555334579528963019774776078145709041408626790537359620871494963640524976715925468729826227647826382793829882465892986157952896301977477607814560125099901270258088705553345795289630197747760781457090414086267905
7、373596208714949636405249767159254687298262276478263827938298824658929861911022696951980024395339106499946762575210011030798928452958382030109486979840142783160416286466410141287127326263322076186058344580905726147852378928979194631762764285561069459137834854349162430367795025513746303535404826972438
8、979139033650489915574745257362885421156393856545506139051074784045967537596183272104105533171282536865715440827419196789454235701500704492885302757740184619492220763297589816999276443927298725750727296736256632277901297323534805254634064824206086455886754992793310542963444100960411469234620234771492480021949937130434545477923053824064847282626724721999683398OUT.DAT1001301090129012901260126012601240144018