全國(guó)計(jì)算機(jī)等級(jí)考試三級(jí)網(wǎng)絡(luò)技術(shù)南開(kāi)上機(jī)100題91100_第1頁(yè)
全國(guó)計(jì)算機(jī)等級(jí)考試三級(jí)網(wǎng)絡(luò)技術(shù)南開(kāi)上機(jī)100題91100_第2頁(yè)
全國(guó)計(jì)算機(jī)等級(jí)考試三級(jí)網(wǎng)絡(luò)技術(shù)南開(kāi)上機(jī)100題91100_第3頁(yè)
全國(guó)計(jì)算機(jī)等級(jí)考試三級(jí)網(wǎng)絡(luò)技術(shù)南開(kāi)上機(jī)100題91100_第4頁(yè)
全國(guó)計(jì)算機(jī)等級(jí)考試三級(jí)網(wǎng)絡(luò)技術(shù)南開(kāi)上機(jī)100題91100_第5頁(yè)
已閱讀5頁(yè),還剩10頁(yè)未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡(jiǎn)介

1、題目91(整數(shù)統(tǒng)計(jì)運(yùn)算題)請(qǐng)編制程序prog1.c,從文件in.dat中讀取200個(gè)整數(shù)至數(shù)組xx中,求出奇數(shù)的個(gè)數(shù)cnt1和偶數(shù)的個(gè)數(shù)cnt2以及數(shù)組xx下標(biāo)為偶數(shù)的元素值的算術(shù)平均值pj(保留2位小數(shù))。    結(jié)果cnt1,cnt2,pj輸出到out.dat中。    部分程序、讀數(shù)據(jù)函數(shù)read_dat(int xx200)及輸出格式已給出。#include <conio.h>#include <stdio.h>#define n 200void read_dat(int xxn)i

2、nt i,j;file *fp;fp=fopen("in.dat","r");for(i=0;i<20;i+)      for(j=0;j<10;j+)         fscanf(fp,"%d,",&xxi*10+j);         printf("%d ",xxi*10+j);

3、printf("n");fclose(fp);void main()int i,j,sum;int cnt1,cnt2,xxn;float pj;file *fw;clrscr();fw=fopen("out.dat","w");read_dat(xx);/*/sum=0; pj=0.0; cnt1=cnt2=0;for(i=0;i<n;i+) if(xxi%2) cnt1+;     else cnt2+;     if(i%2=0) pj+=xx

4、i;sum+;pj/=sum;/*/printf("nncnt1=%d,cnt2=%d,pj=%6.2fn",cnt1,cnt2,pj);fprintf(fw,"%dn%dn%6.2fn",cnt1,cnt2,pj);fclose(fw);*題目92(整數(shù)統(tǒng)計(jì)運(yùn)算題)請(qǐng)編制程序prog1.c,從文件in.dat中讀取200個(gè)整數(shù)至數(shù)組xx中,求出最大數(shù)max及最大數(shù)的個(gè)數(shù)cnt和數(shù)組xx中能被3整除或能被7整除的算術(shù)平均值pj(保留2位小數(shù))。    結(jié)果max,cnt,pj輸出到out.dat中。 &#

5、160;  部分程序、讀數(shù)據(jù)函數(shù)read_dat(int xx200)及輸出格式已給出。#include <conio.h>#include <stdio.h>#define n 200void read_dat(int xxn)int i,j;file *fp;fp=fopen("in.dat","r");for(i=0;i<20;i+)      for(j=0;j<10;j+)     

6、0;   fscanf(fp,"%d,",&xxi*10+j);         printf("%d",xxi*10+j);printf("n");fclose(fp);void main()int m,temp,n,sum;int cnt,xxn,max ;float pj;file *fw;clrscr();fw=fopen("out.dat","w");read_dat(xx);/

7、*/cnt=0; max=xx0; pj=0.0; n=0;for(m=0;m<n;m+)    if(max<xxm) max=xxm;for(m=0;m<n;m+)    if(xxm=max) cnt+;     if(xxm%3=0|xxm%7=0)        pj+=xxm; n+;     pj/=n;/*/printf("nnmax=%d,cnt=%d

8、,pj=%6.2fn",max,cnt,pj);fprintf(fw,"%dn%dn%6.2fn",max,cnt,pj);fclose(fw);*題目93(方差運(yùn)算題)請(qǐng)編制函數(shù)readdat()實(shí)現(xiàn)從文件in.dat中讀取1000個(gè)十進(jìn)制整數(shù)到數(shù)組xx中;請(qǐng)編制函數(shù)compute(),分別計(jì)算出xx中奇數(shù)的個(gè)數(shù)odd,偶數(shù)的個(gè)數(shù)even,平均值aver以及方差totfc的值,最后調(diào)用函數(shù)writedat()把結(jié)果輸出到out.dat文件中。    計(jì)算方差的公式如下:     &#

9、160;        n         2     totfc=1/n (xxi-aver)              i=1    原始數(shù)據(jù)文件存放的格式是:每行存放10個(gè)數(shù),并用逗號(hào)隔開(kāi)。(每個(gè)數(shù)均大于0且小于等于2000)

10、0;   部分源程序存在文件prog1.c中。    請(qǐng)勿改動(dòng)主函數(shù)main()和輸出數(shù)據(jù)函數(shù)writedat()的內(nèi)容。#include <stdio.h>#include <stdlib.h>#include <string.h>#define max 1000int xxmax,odd=0,even=0;double aver=0.0,totfc=0.0;void writedat(void);int readdat(void)int i;file *fp;if(fp=fopen(&

11、quot;in.dat","r")=null) return 1;/*編制函數(shù)readdat()*/for(i=0;i<max;i+) fscanf(fp,"%d,",&xxi);     if(i+1)%10=0)     fscanf(fp,"n");/*/fclose(fp);return 0;void compute(void) int i;for(i=0;i<max;i+)    if(

12、xxi%2) odd+;      else even+;      aver+=xxi;    aver/=max;for(i=0;i<max;i+)     totfc+=(xxi-aver)*(xxi-aver);totfc/=max;void main()int i;for(i=0;i<max;i+)xxi=0;if(readdat()    printf("數(shù)據(jù)文件

13、in.dat不能打開(kāi)!007n");    return;compute();printf("odd=%dnoven=%dnaver=%fntotfc=%fn",odd,even,aver,totfc);writedat();void writedat(void)file *fp;int i;fp=fopen("out.dat","w");fprintf(fp,"%dn%dn%fn%fn",odd,even,aver,totfc);fclose(fp);*題目94(整數(shù)統(tǒng)計(jì)運(yùn)

14、算題)請(qǐng)編制程序prog1.c,從文件in.dat中讀取200個(gè)整數(shù)至數(shù)組xx中,求出奇數(shù)的個(gè)數(shù)cnt1和偶數(shù)的個(gè)數(shù)cnt2以及數(shù)組xx中值為偶數(shù)的算術(shù)平均值pj(保留2位小數(shù))。    結(jié)果cnt1,cnt2,pj輸出到out.dat中。    部分程序、讀數(shù)據(jù)函數(shù)read_dat(int xx200)及輸出格式已給出。#include <conio.h>#include <stdio.h>#define n 200void read_dat(int xxn)int i,j;file *f

15、p;fp=fopen("in.dat","r");for(i=0;i<20;i+)      for(j=0;j<10;j+)         fscanf(fp,"%d,",&xxi*10+j);         printf("%d ",xxi*10+j);printf("n

16、");fclose(fp);void main()int m,sum;int cnt1,cnt2,xxn;float pj;file *fw;fw=fopen("out.dat","w");clrscr();read_dat(xx);/*/cnt1=0; cnt2=0; pj=0.0;for(m=0;m<n;m+)    if(xxm%2) cnt1+;    else cnt2+; pj+=xxm;if(cnt2=0) pj=0;else pj/=cnt2;/*/printf(

17、"nncnt1=%d,cnt2=%d,pj=%6.2fn",cnt1,cnt2,pj);fprintf(fw,"%dn%dn%6.2fn",cnt1,cnt2,pj);fclose(fw);*題目95(字符替換題)函數(shù)readdat()實(shí)現(xiàn)從文件eng.in中讀取一篇英文文章,存入到字符串?dāng)?shù)組xx中;請(qǐng)編制函數(shù)encryptchar(),按給定的替代關(guān)系對(duì)數(shù)組xx中的所有字符進(jìn)行替代,仍存入數(shù)組xx的對(duì)應(yīng)的位置上,最后調(diào)用函數(shù)writedat()把結(jié)果xx輸出到文件ps4.da中。替代關(guān)系:f(p)=p*11 mod 256(p是數(shù)組中某一個(gè)字符的asc

18、ii值,f(p)是計(jì)算后新字符的ascii值),如果計(jì)算后f(p)值小于等于32或f(p)對(duì)應(yīng)的字符是大寫(xiě)字母,則該字符不變,否則將f(p)所對(duì)應(yīng)的字符進(jìn)行替代。部分源程序存在文件prog1.c中。原始數(shù)據(jù)文件存放的格式是:每行的寬度均小于80個(gè)字符。請(qǐng)勿改動(dòng)主函數(shù)main()、讀數(shù)據(jù)函數(shù)readdat()和輸出數(shù)據(jù)函數(shù)writedat()的內(nèi)容。#include <stdio.h>#include <string.h>#include <conio.h>#include <ctype.h>unsigned char xx5080;int max

19、line=0;/*文章的總行數(shù)*/int readdat(void);void writedat(void);void encryptchar() int i,j;for(i=0;i<maxline;i+)    for(j=0;j<strlen(xxi);j+)     if(xxij*11%256<=32|xxij*11%256>='a'&&xxij*11%256<='z') continue;    

20、else xxij=xxij*11%256;void main()clrscr();if(readdat()printf("數(shù)據(jù)文件eng.in不能打開(kāi)!n007");return;encryptchar();writedat();int readdat(void)file *fp;int i=0;unsigned char *p;if(fp=fopen("eng.in","r")=null) return 1;while(fgets(xxi,80,fp)!=null)    p=strchr(xxi,&

21、#39;n');    if(p)*p=0;    i+;maxline=i;fclose(fp);return 0;void writedat(void)file *fp;int i;fp=fopen("ps4.dat","w");for(i=0;i<maxline;i+)printf("%sn",xxi);fprintf(fp,"%sn",xxi);fclose(fp);題目96(字符替換題)函數(shù)readdat()實(shí)現(xiàn)從文件eng.in中

22、讀取一篇英文文章,存入到字符串?dāng)?shù)組xx中;請(qǐng)編制函數(shù)encryptchar(),按給定的替代關(guān)系對(duì)數(shù)組xx中的所有字符進(jìn)行替代,仍存入數(shù)組xx的對(duì)應(yīng)的位置上,最后調(diào)用函數(shù)writedat()把結(jié)果xx輸出到文件ps5.dat中。替代關(guān)系:f(p)=p*11mod 256 (p是數(shù)組中某一個(gè)字符的ascii值,f(p)是計(jì)算后新字符的ascii值),如果原字符是小寫(xiě)字母或計(jì)算后f(p)值小于等于32,則該字符不變,否則將f(p)所對(duì)應(yīng)的字符進(jìn)行替代。部分源程序存在文件prog1.c中。原始數(shù)據(jù)文件存放的格式是:每行的寬度均小于80個(gè)字符。請(qǐng)勿改動(dòng)主函數(shù)main()、讀數(shù)據(jù)函數(shù)readdat()和

23、輸出數(shù)據(jù)函數(shù)writedat()的內(nèi)容。#include <stdio.h>#include <string.h>#include <conio.h>#include <ctype.h>unsigned char xx5080;int maxline=0;/*文章的總行數(shù)*/int readdat(void);void writedat(void);void encryptchar() int i,j;for(i=0;i<maxline;i+)    for(j=0;j<strlen(xxi);j+)&#

24、160;    if(xxij*11%256<=32|xxij>='a'&&xxij<='z') continue;     else xxij=xxij*11%256;void main()clrscr();if(readdat()printf("數(shù)據(jù)文件eng.in不能打開(kāi)!n007");return;encryptchar();writedat();int readdat(void)file *fp;int i=0;unsigned

25、char *p;if(fp=fopen("eng.in","r")=null) return 1;while(fgets(xxi,80,fp)!=null)    p=strchr(xxi,'n');    if(p)*p=0;    i+;maxline=i;fclose(fp);return 0;void writedat(void)file *fp;int i;fp=fopen("ps5.dat","w"

26、);for(i=0;i<maxline;i+)printf("%sn",xxi);fprintf(fp,"%sn",xxi);fclose(fp);*題目97(字符替換題)函數(shù)readdat()實(shí)現(xiàn)從文件eng.in中讀取一篇英文文章,存入到字符串?dāng)?shù)組xx中;請(qǐng)編制函數(shù)encryptchar(),按給定的替代關(guān)系對(duì)數(shù)組xx中的所有字符進(jìn)行替代,仍存入數(shù)組xx的對(duì)應(yīng)的位置上,最后調(diào)用函數(shù)writedat()把結(jié)果xx輸出到文件ps9.dat中。替代關(guān)系:f(p)=p*11 mod 256(p是數(shù)組中某一個(gè)字符的ascii值,f(p)是計(jì)算后新字符的a

27、scii值),如果原字符是數(shù)字字符0至9或計(jì)算后f(p)值小于等于32,則該字符不變,否則將f(p)所對(duì)應(yīng)的字符進(jìn)行替代。部分源程序存在文件prog1.c中。原始數(shù)據(jù)文件存放的格式是:每行的寬度均小于80個(gè)字符。請(qǐng)勿改動(dòng)主函數(shù)main()、讀數(shù)據(jù)函數(shù)readdat()和輸出數(shù)據(jù)函數(shù)writedat()的內(nèi)容。#include <stdio.h>#include <string.h>#include <conio.h>#include <ctype.h>unsigned char xx5080;int maxline=0;/*文章的總行數(shù)*/int

28、 readdat(void);void writedat(void);void encryptchar() int i,j;for(i=0;i<maxline;i+)    for(j=0;j<strlen(xxi);j+)     if(xxij*11%256<=32|xxij>='0'&&xxij<='9') continue;     else xxij=xxij*11%256;void main()c

29、lrscr();if(readdat()printf("數(shù)據(jù)文件eng.in不能打開(kāi)!n007");return;encryptchar();writedat();int readdat(void)file *fp;int i=0;unsigned char *p;if(fp=fopen("eng.in","r")=null) return 1;while(fgets(xxi,80,fp)!=null)    p=strchr(xxi,'n');    if(

30、p)*p=0;    i+;maxline=i;fclose(fp);return 0;void writedat(void)file *fp;int i;fp=fopen("ps9.dat","w");for(i=0;i<maxline;i+)printf("%sn",xxi);fprintf(fp,"%sn",xxi);fclose(fp);*題目98(字符替題) 函數(shù)readdat()實(shí)現(xiàn)從文件eng.in中讀取一篇英文文章,存入到字符串?dāng)?shù)組xx中;請(qǐng)編制函數(shù)encrypt

31、char(),按給定的替代關(guān)系對(duì)數(shù)組xx中的所有字符進(jìn)行替代,仍存入數(shù)組xx的對(duì)應(yīng)的位置上,最后調(diào)用函數(shù)writedat()把結(jié)果xx輸出到文件ps3.dat中。替代關(guān)系:f(p)=p*17 mod 256(p是數(shù)組中某一個(gè)字符的ascii值,f(p)是計(jì)算后新字符的ascii值),如果計(jì)算后f(p)值小于等于32或其ascii值是奇數(shù),則該字符不變,否則將f(p)所對(duì)應(yīng)的字符進(jìn)行替代。部分源程序存在文件prog1.c中。原始數(shù)據(jù)文件存放的格式是:每行的寬度均小于80個(gè)字符。請(qǐng)勿改動(dòng)主函數(shù)main()、讀數(shù)據(jù)函數(shù)readdat()和輸出數(shù)據(jù)函數(shù)writedat()的內(nèi)容。#include &l

32、t;stdio.h>#include <string.h>#include <conio.h>#include <ctype.h>unsigned char xx5080;int maxline=0;/*文章的總行數(shù)*/int readdat(void);void writedat(void);void encryptchar() int i,j;for(i=0;i<maxline;i+)    for(j=0;j<strlen(xxi);j+)     if(xxij*

33、17%256<=32|(xxij*17%256)%2!=0) continue;     else xxij=xxij*17%256;void main()clrscr();if(readdat()printf("數(shù)據(jù)文件eng.in不能打開(kāi)!n007");return;encryptchar();writedat();int readdat(void)file *fp;int i=0;unsigned char *p;if(fp=fopen("eng.in","r")=null) ret

34、urn 1;while(fgets(xxi,80,fp)!=null)    p=strchr(xxi,'n');    if(p)*p=0;    i+;maxline=i;fclose(fp);return 0;void writedat(void)file *fp;int i;fp=fopen("ps3.dat","w");for(i=0;i<maxline;i+)printf("%sn",xxi);fprintf(f

35、p,"%sn",xxi);fclose(fp);*題目99(結(jié)構(gòu)體排列題)已知在文件in.dat中存有100個(gè)產(chǎn)品銷售記錄,每個(gè)產(chǎn)品銷售記錄由產(chǎn)品代碼dm(字符型4位),產(chǎn)品名稱mc(字符型10位),單價(jià)dj(整型),數(shù)量sl(整型),金額je(長(zhǎng)整型)五部分組成。其中:金額=單價(jià)*數(shù)量計(jì)算得出。函數(shù)readdat()是讀取這100個(gè)銷售記錄并存入結(jié)構(gòu)數(shù)組sell中。請(qǐng)編制函數(shù)sortdat(),其功能要求:按金額從小到大進(jìn)行排列,若金額相等,則按產(chǎn)品代碼從小到大進(jìn)行排列,最終排列結(jié)果仍存入結(jié)構(gòu)數(shù)組sell中,最后調(diào)用函數(shù)writedat()把結(jié)果輸出到文件out1.dat

36、中。    部分源程序存在文件prog1.c中。請(qǐng)勿改動(dòng)主函數(shù)main()、讀數(shù)據(jù)函數(shù)readdat()和輸出數(shù)據(jù)函數(shù)writedat()的內(nèi)容。#include <stdio.h>#include <mem.h>#include <string.h>#include <conio.h>#include <stdlib.h>#define max 100typedef structchar dm5; /*產(chǎn)品代碼*/char mc11; /*產(chǎn)品名稱*/int dj;  &#

37、160;    /*單價(jià)*/int sl;       /*數(shù)量*/long je;      /*金額*/pro;pro sellmax;void readdat();void writedat();void sortdat()int i,j;pro xy;for(i=0;i<99;i+)for(j=i+1;j<100;j+)     if(selli.je>sellj.je|selli.je=s

38、ellj.je&&strcmp(selli.dm,sellj.dm)>0)        xy=selli;sell i=sellj;sellj=xy;void main()memset(sell,0,sizeof(sell);readdat();sortdat();writedat();void readdat()file *fp;char str80,ch11;int i;fp=fopen("in.dat","r");for(i=0;i<100;i+)&

39、#160;   fgets(str,80,fp);    memcpy(selli.dm,str,4);    memcpy(selli.mc,str+4,10);    memcpy(ch,str+14,4);ch4=0;    selli.dj=atoi(ch);    memcpy(ch,str+18,5);ch5=0;    selli.sl=atoi(ch);  &#

40、160; selli.je=(long)selli.dj*selli.sl;fclose(fp);void writedat()file *fp;int i;fp=fopen("out1.dat","w");for(i=0;i<100;i+)printf("%s %s %4d %5d %5dn", selli.dm,selli.mc,selli.dj,selli.sl,selli.je);fprintf(fp,"%s %s %4d %5d %5dn", selli.dm,selli.mc,selli.dj,selli.sl,selli.je);fclose(fp);*題目100(字符替換題)函數(shù)readdat()實(shí)現(xiàn)從文件in.dat中讀取一篇英文文章存入到字符串?dāng)?shù)組xx中,請(qǐng)編制函數(shù)charconva(),其函數(shù)的功能是:以行為單位把字符串中的最后一個(gè)字符的ascii值右移4位,高位補(bǔ)0后加最后第二個(gè)字符的ascii值,得到最后一個(gè)新的字符,最后第二個(gè)字符的ascii值右移4位,高位補(bǔ)0后加最后第三個(gè)字符的ascii值,

溫馨提示

  • 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

評(píng)論

0/150

提交評(píng)論