for(i=0;i printf(\ if((i+1)%5==0) printf(\ } k=find(a,N); if(k==0) printf(\ else printf(\ wwjt(); } void wwjt() { FILE *IN,*OUT; int n; int i[5]; int o; IN=fopen(\ if(IN==NULL) { printf(\ } OUT=fopen(\ if(OUT==NULL) { printf(\ } for(n=0;n<5;n++) { fscanf(IN,\ } o=find(i,5); fprintf(OUT,\ fclose(IN); fclose(OUT); } 4、题目:分别统计字符串中字母、数字、空格和其他字符出现的次数(字符长度小于80)。 #include int a=0,num=0,b=0,other=0; /*全局变量a用于保存字母个数,num用于保存数字个数, b用于保存空格个数,other用于保存其他字符字数*/ void count(char c[]) { - 29 - /**********Program**********/ int i; for(i=0;c[i]!='\\0';i++) if((c[i]>='A'&&c[i]<='Z')||(c[i]>='a'&&c[i]<='z')) a=a+1; else if(c[i]>='0'&&c[i]<='9') num=num+1; else if (c[i]==' ') b=b+1; else other=other+1; /********** End **********/ } void main() { char ch[80]; printf (\ gets(ch); count(ch); printf (\ wwjt(); } void wwjt() { FILE *IN,*OUT; int i; char sin[80]; IN=fopen(\ if(IN==NULL) { printf(\erify The Currernt Dir..it May Be Changed\ } OUT=fopen(\ if(OUT==NULL) { printf(\erify The Current Dir.. it May Be Changed\ } for(i=0;i<5;i++) { a=0; num=0; b=0; other=0; fscanf(IN,\ count(sin); fprintf(OUT,\ fprintf(OUT,\ fprintf(OUT,\ - 30 - fprintf(OUT,\ } fclose(IN); fclose(OUT); } 5、功能:求给定正整数n以内的素数之积。(n<28) #include /**********Program**********/ long i,k; long s=1; for(i=2;i<=n;i++) { for(k=2;k if(i%k==0) break; if(k==i) s=s*i; } return s; /********** End **********/ } main() { int m; printf(\ scanf(\ printf(\ wwjt(); } void wwjt() { FILE *IN,*OUT; int c ; int t; long o; IN=fopen(\ if(IN==NULL) { printf(\ } OUT=fopen(\ if(OUT==NULL) - 31 - { printf(\ } for(c=1;c<=5;c++) { fscanf(IN,\ o=fun(t); fprintf(OUT,\ } fclose(IN); fclose(OUT); } --The End-- - 32 -