資源描述:
《全國計算機等級考試三級C語言上機100題1》由會員上傳分享,免費在線閱讀,更多相關內容在教育資源-天天文庫。
??C100???1??jsValue(intm,intk,intxx[D+,??./012?4??m67?m?k9?:?????BC??writeDat?GH100;m++)if(isP(m)){xx[s++]=m;k—;})main()(intm,n,xx[1000];clrscr();printf("
1Pleaseentertwointegers:'*);scanf("d%d\&m,&n);num(m,n,xx);for(m=0;m2n);readwriteDat();)voidreadwriteDat()(intm,n,xx[1000],i;FILE
3rf=fopen("in.dat,,,'+rn);wf=fopen(,'out.dat,\',w");for(i=0;i<10;i++){fscanf(rf/%d%du,&m,&n);num(m,n,xx);for(m=0;m)fclose(rf)fclose(wf);??2?I?TIN.DATX:?200?+C?G?readDat?P?:??4fclose(fp);voidmain()(inti;readDat();jsVal();printf("??T??=%d
5”,ent);for(i=0;i6");writeDatO)writeDat()(FILE*fp;inti;fp=fopenC^ut.dat",nwu);fprintf(fp,"%d
7",ent);for(i=0;i8,',b[i]);fclose(fp);??3?ReadDat()·?¥?TIN.DATXGH1o???:??a??9intReadDat(void);voidWriteDat(void);voidStrOR(void){inti,righto,j,s,k;chartem[80J;for(i=0;ifor(j=strlen(xx[i])-l;j>=O;j—){k=0;memset(tem,0,80);if(xx[ij[j]=='o,){righto=j;for(s=righto+1;stem[k++]=xx[i][s];for(s=0;sif(xx[i][s]!=o')tem[k++]=xx[i][s];strcpy(xx[i],tem);)elsecontinue;voidmain(){clrscr();if(ReadDat()){printf("?I?TIN.DATa/??!
10\007");return;)StrOR();WriteDat();)intReadDat(void){FILE*fp;inti=0;char*p;if((fp=fopenCIN.DAT"JT"))==NULL)return1;while(fgets(xx[i],80,fp)!=NULL){p=strchr(xx[i],'
11');
12if(p)*p=0;i++;)maxline=i;fclose(fp);return0;)voidWriteDat(void)(FILE*fp;inti;clrscr();fp=fopen("OUT5.DAT“+“w")for(i=0;i13,',xx[ij);fprintf(fp,u%s
14n,xx[i]);)fclose(fp);??4?ReadDat?·?¥?TIN.DATXGH1o???:??a??15intReadDat(void);voidWriteDat(void);voidStrOL(void){inti,j,k,s,m,strl;charstr[80];for(i=0;i=O;j-){if(isalpha(xx[i][j]))k++;else{for(m=1;m<=k;m++)str[s+4-]=xx[i][j+m];k=0;)if(!isalpha(xx[i][j]))str[s++]='*;)for(m=1;m<=k;m++)str[s++]=xx[i][j+m];str[s]=^';strcpy(xx[i],str);}voidmain()(clrscr();if(ReadDat()){printf("?I?TIN.DATa/??ì
16\007”);return;)StrOU);WriteDat();intReadDat(void)1FILE*fp;inti=0;char*p;if((fp=fopen(,,IN.DAT,,,r"))==NULL)return1;while(fgets(xx[i],80,fp)!=NULL){
17p=strchr(xx[i]An*);if(p)*p=O;i++)maxline=i;fclose(fp);return0;)voidWriteDat(void)(FILE*fp;inti;clrscr();fp=fopen(nOUT6.DATu,wu);for(i=0;i18”,xx[i]);fprintf(fp,H%s
19H,xx[i]);)fclose(fp);??5??Tin.datX?200í??+6????1000?9999D???ReadDat()GH200?:è??20for(i=0;i<199;i++)for(j=i+lj<200;j++)if(aafi]%1000>aa[j]%1000llaa[i]%1000==aa[j]%1000&&aa[i]for(i=0;i<10;i++)bb[i]=aa[i];)voidmain()(readDat();jsSort();writeDat();)readDat()(FILE*in;inti;in=fopen(,,in.datu,,,rM);for(i=0;i<200;i++)fscanf(in,n%d\&aa[i]);fclose(in);)writeDat()(FILE*out;inti;clrscr();out=fopen("out.dat,',,,wu);for(i=0;i<10;i++){printf(n%d,',bb[i]);fprintf(out,n%d
21H,bb[i]);)fclose(out);)??6??Tin.datX?200í??+6????1000?9999D???ReadDat?GH200?:è??22?Tout.datX?a1???90125099601270258088??B50998088702560129012?1Y?Z[\?ùM?l?no?main??G?I?ReadDat?pQM?I?WriteDat???r?#include#include#includeintaa[200],bb[10];voidjsSort()(inti,j,data;for(i=0;i<199;i-H-)for(j=i+lj<200;j++)if(aali]%1000aa|jJ){data=aa[i];aa[i]=aa[jl;aa[jl=data;}for(i=0;i<10;i++)bb[i]=aa[i];)voidmain()(readDat();jsSort();writeDat();systemCpause");)readDat()(FILE*in;inti;in=fopen("in.dat,,,',rn);for(i=0;i<200;i++)fscanf(in,H%d,M,&aa[i]);fclose(in);)writeDat()FILE*oul;
23inti;clrscr();out=fopen("out.dat",nwn);for(i=0;i<10;i++){printf(ni=%d,%d
24n,i+l,bb[i]);fprintf(outj%d
25",bb[i]);}fclose(out);)??7??TIN.DATX:?100ú?├yt?