九九热最新网址,777奇米四色米奇影院在线播放,国产精品18久久久久久久久久,中文有码视频,亚洲一区在线免费观看,国产91精品在线,婷婷丁香六月天

歡迎來到裝配圖網(wǎng)! | 幫助中心 裝配圖網(wǎng)zhuangpeitu.com!
裝配圖網(wǎng)
ImageVerifierCode 換一換
首頁 裝配圖網(wǎng) > 資源分類 > DOC文檔下載  

全國計算機等級考試 三級C語言上機題庫 上機100題

  • 資源ID:161517378       資源大?。?span id="24d9guoke414" class="font-tahoma">615KB        全文頁數(shù):52頁
  • 資源格式: DOC        下載積分:10積分
快捷下載 游客一鍵下載
會員登錄下載
微信登錄下載
三方登錄下載: 微信開放平臺登錄 支付寶登錄   QQ登錄   微博登錄  
二維碼
微信掃一掃登錄
下載資源需要10積分
郵箱/手機:
溫馨提示:
用戶名和密碼都是您填寫的郵箱或者手機號,方便查詢和重復(fù)下載(系統(tǒng)自動生成)
支付方式: 支付寶    微信支付   
驗證碼:   換一換

 
賬號:
密碼:
驗證碼:   換一換
  忘記密碼?
    
友情提示
2、PDF文件下載后,可能會被瀏覽器默認打開,此種情況可以點擊瀏覽器菜單,保存網(wǎng)頁到桌面,就可以正常下載了。
3、本站不支持迅雷下載,請使用電腦自帶的IE瀏覽器,或者360瀏覽器、谷歌瀏覽器下載即可。
4、本站資源下載后的文檔和圖紙-無水印,預(yù)覽文檔經(jīng)過壓縮,下載后原文更清晰。
5、試題試卷類文檔,如果標題沒有明確說明有答案則都視為沒有答案,請知曉。

全國計算機等級考試 三級C語言上機題庫 上機100題

全國計算機等級考試三級C語言上機100題(2011年9月)為解決大部分考生使用網(wǎng)上不同的南開100題,造成對各個版本的解題方法各有不同的疑惑,加上很多解題不易理解,容易產(chǎn)生誤解,現(xiàn)綜合本論壇會員的反聵,以及2011年3月實際上機考試的情況,特對100題進行重新編排修訂。幾點說明:1、題目標題號前用“”顯示的是2005年4月份本人根據(jù)各大論壇考生聵的題號集中而來,題號前加“”為2005年9月上機考試題,其中難免有題型相同而題號增加的現(xiàn)象,此類標明,僅供參考。2、每種題目,只用一種解題方法,蘭色部分為解題答案,此種方法本人覺得容易理解,不易出錯,適合初學(xué)者。3、特別說明:所有解法,本人均上機驗證通過。4、個別南開題如57、100題,題目與原書有所不同,是按實際考試的題目所來,并對今年在實際上機中出現(xiàn)的考題,用紅色部分表示實際上機題中的注明事項。全國計算機等級考試論壇 : 題目1請編寫一個函數(shù)jsValue(int m,int k,int xx),該函數(shù)的功能是:將大于整數(shù)m且緊靠m的k個素數(shù)存入數(shù)組xx傳回。 最后調(diào)用函數(shù)writeDat()讀取10組數(shù)據(jù),分別得出結(jié)果且把結(jié)果輸出到文件out.dat中。 部分源程序存在文件prog1.c中。 例如:若輸入17 5 則應(yīng)輸出:19,23,29,31,37。 請勿改動主函數(shù)main()和寫函數(shù)writeDat()的內(nèi)容。#include <conio.h>#include <stdio.h>void readwriteDat();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 s=0; for(m=m+1;k>0;m+) if(isP(m) xxs+=m; k-;main() int m,n,xx1000; clrscr(); printf("nPlease enter two integers:"); scanf("%d%d",&m,&n); num(m,n,xx); for(m=0;m<n;m+) printf("%d ",xxm); printf("n"); readwriteDat();void readwriteDat() int m,n,xx1000, 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 ",xxm); fprintf(wf,"n"); fclose(rf); fclose(wf); 題目2已知數(shù)據(jù)文件IN.DAT中存有200個四位數(shù),并已調(diào)用讀函數(shù)readDat()把這些數(shù)存入數(shù)組a中,請考生編制一函數(shù)jsVal(),其功能是:如果四位數(shù)各位上的數(shù)字均是0或2或4或6或8,則統(tǒng)計出滿足此條件的個數(shù)cnt,并把這些四位數(shù)按從大到小的順序存入數(shù)組b中。最后main( )函數(shù)調(diào)用寫函數(shù)writeDat()把結(jié)果cnt以及數(shù)組b中符合條件的四位數(shù)輸出到OUT.DAT文件中。 注意:部分源程序存在文件prog1.c中。 程序中已定義數(shù)組:a200,b200,已定義變量:cnt 請勿改動數(shù)據(jù)文件IN.DAT中的任何數(shù)據(jù)、主函數(shù)main()、讀函數(shù)readDat()和寫函數(shù)writeDat()的內(nèi)容。#include <stdio.h>#define MAX 200int aMAX, bMAX, cnt = 0 ;void jsVal() int i,j,qw,bw,sw,gw; for(i=0;i<MAX;i+) qw=ai/1000; bw=ai/100%10; sw=ai%100/10; gw=ai%10; if(qw&&qw%2=0&&bw%2=0&&sw%2=0&&gw%2=0) bcnt+=ai; for(i=0;i<cnt-1;i+) for(j=i+1;j<cnt;j+) if(bi<bj) qw=bi; bi=bj; bj=qw;void readDat() int i ; FILE *fp ; fp = fopen("in.dat", "r") ; for(i = 0 ; i < MAX ; i+) fscanf(fp, "%d", &ai) ; fclose(fp) ;void main() int i ; readDat() ; jsVal() ; printf("滿足條件的數(shù)=%dn", cnt) ; for(i = 0 ; i < cnt ; i+) printf("%d ", bi) ; printf("n") ; writeDat() ;writeDat() FILE *fp ; int i ; fp = fopen("out.dat", "w") ; fprintf(fp, "%dn", cnt) ; for(i = 0 ; i < cnt ; i+) fprintf(fp, "%dn", bi) ; fclose(fp) ;題目3函數(shù)ReadDat( )實現(xiàn)從文件IN.DAT中讀取一篇英文文章存入到字符串數(shù)組xx中;請編制函數(shù)StrOR( ),其函數(shù)的功能是:以行為單位依次把字符串中所有小寫字母o左邊的字符串內(nèi)容移到該串的右邊存放,然后把小寫字母o刪除,余下的字符串內(nèi)容移到已處理字符串的左邊存放,之后把已處理的字符串仍按行重新存入字符串數(shù)組xx中。最后main()函數(shù)調(diào)用函數(shù)WriteDat()把結(jié)果xx輸出到文件OUT5.DAT中。 原始數(shù)據(jù)文件存放的格式是:每行的寬度均小于80個字符,含標點符號和空格。 注意:部分源程序存放在文件prog1.c中。 請勿改動主函數(shù)main()、讀數(shù)據(jù)函數(shù)ReadDat()和輸出數(shù)據(jù)函數(shù)WriteDat()的內(nèi)容。#include <stdio.h>#include <string.h>#include <conio.h>char xx5080 ;int maxline = 0 ; /* 文章的總行數(shù) */int ReadDat(void) ;void WriteDat(void) ;void StrOR(void)int i,righto,j,s,k; char tem80; for(i=0;i<maxline;i+) for(j=strlen(xxi)-1;j>=0;j-) k=0; memset(tem,0,80); if(xxij='o') righto=j; for(s=righto+1;s<strlen(xxi);s+) temk+=xxis; for(s=0;s<righto;s+) if(xxis!='o') temk+=xxis; strcpy(xxi,tem); else continue; void main() clrscr() ; if(ReadDat() printf("數(shù)據(jù)文件IN.DAT不能打開!n007") ; return ; StrOR() ; WriteDat() ;int ReadDat(void) FILE *fp ; int i = 0 ; char *p ; if(fp = fopen("IN.DAT", "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 ; clrscr() ; fp = fopen("OUT5.DAT", "w") ; for(i = 0 ; i < maxline ; i+) printf("%sn", xxi) ; fprintf(fp, "%sn", xxi) ; fclose(fp) ;題目4函數(shù)ReadDat()實現(xiàn)從文件IN.DAT中讀取一篇英文文章存入到字符串數(shù)組xx中,請編制函數(shù)StrOL(),其函數(shù)的功能是:以行為單位對行中以空格或標點符號為分隔的所有單詞進行倒排。最后把已處理的字符串(應(yīng)不含標點符號)仍按行重新存入字符串數(shù)組xx中,最后調(diào)用函數(shù)writeDat()把結(jié)果xx輸出到文件OUT6.DAT中。 例如:原文:You He Me I am a student.結(jié)果:Me He You student a am I 原始數(shù)據(jù)文件存放的格式是:每行的寬度均小于80個字符,含標點符號和空格。 部分源程序存在文件prog1.c中。 請勿改動主函數(shù)main()、讀數(shù)據(jù)函數(shù)ReadDat()和輸出數(shù)據(jù)函數(shù)writeDat()的內(nèi)容。#include <stdio.h>#include <string.h>#include <conio.h>#include <ctype.h>char xx5080;int maxline=0;/*文章的總行數(shù)*/int ReadDat(void);void WriteDat(void);void StrOL(void) int i,j,k,s,m,strl; char str80; for(i=0;i<maxline;i+) strl=strlen(xxi);memset(str,0,80); s=k=0;for(j=strl-1;j>=0;j-) if(isalpha(xxij) k+; else for(m=1;m<=k;m+) strs+=xxij+m; k=0; if(!isalpha(xxij) strs+=' ' for(m=1;m<=k;m+) strs+=xxij+m;strs='0' strcpy(xxi,str); void main() clrscr(); if(ReadDat() printf("數(shù)據(jù)文件IN.DAT不能打開!n007"); return; StrOL(); WriteDat();int ReadDat(void) FILE *fp; int i=0; char *p; if(fp=fopen("IN.DAT","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; clrscr(); fp=fopen("OUT6.DAT","w"); for(i=0;i<maxline;i+) printf("%sn",xxi); fprintf(fp,"%sn",xxi); fclose(fp);題目5(整數(shù)排序題)在文件in.dat中有200個正整數(shù),且每個數(shù)均在1000至9999之間。函數(shù)ReadDat()讀取這200個數(shù)存放到數(shù)組aa中。請編制函數(shù)jsSort(),其函數(shù)的功能是:要求按每個數(shù)的后三位的大小進行升序排列,然后取出滿足此條件的前10個數(shù)依次存入數(shù)組bb中,如果后三位的數(shù)值相等,則按原先的數(shù)值進行降序排列。最后調(diào)用函數(shù)WriteDat()把結(jié)果bb輸出到文件out.dat中。 例:處理前 6012 5099 9012 7025 8088 處理后 9012 6012 7025 8088 5099 部分源程序存在文件prog1.c中。請勿改動主函數(shù)main()、讀數(shù)據(jù)函數(shù)ReadDat()和輸出數(shù)據(jù)函數(shù)WriteDat()的內(nèi)容。#include <stdio.h>#include <string.h>#include <conio.h>int aa200,bb10;void jsSort() int i,j,data; for(i=0;i<199;i+) for(j=i+1;j<200;j+) if(aai%1000>aaj%1000|aai%1000=aaj%1000&&aai<aaj) data=aai;aai=aaj;aaj=data; for(i=0;i<10;i+) bbi=aai;void main() readDat(); jsSort(); writeDat();readDat() FILE *in; int i; in=fopen("in.dat","r"); for(i=0; i<200; i+) fscanf(in,"%d,",&aai); fclose(in); writeDat() FILE *out; int i; clrscr(); out=fopen("out.dat","w"); for(i=0; i<10; i+) printf(" %d",bbi); fprintf(out,"%dn",bbi); fclose(out);題目6 正整數(shù)排序在文件in.dat中有200個正整數(shù),且每個數(shù)均在1000至9999之間。函數(shù)ReadDat()讀取這200個數(shù)存放到數(shù)組aa中。請編制函數(shù)jsSort(),其函數(shù)的功能是:要求按每個數(shù)的后三位的大小進行降序排列,然后取出滿足此條件的前10個數(shù)依次存入數(shù)組b中,如果后三位的數(shù)值相等,則按原先的數(shù)值進行升序排列。最后調(diào)用函數(shù)WriteDat()把結(jié)果bb輸出到文件out.dat中。例:處理前 9012 5099 6012 7025 8088 處理后 5099 8088 7025 6012 9012 注意:部分源程序已給出。請勿改動主函數(shù)main()、讀數(shù)據(jù)函數(shù)ReadDat()和輸出數(shù)據(jù)函數(shù)WriteDat()的內(nèi)容。 #include<stdio.h>#include<string.h>#include<conio.h>int aa200,bb10;void jsSort() int i,j,data; for(i=0;i<199;i+) for(j=i+1;j<200;j+) if(aai%1000<aaj%1000|aai%1000=aaj%1000&&aai>aaj) data=aai;aai=aaj;aaj=data; for(i=0;i<10;i+) bbi=aai;void main()readDat();jsSort();writeDat();system("pause");readDat()FILE *in;int i;in=fopen("in.dat","r");for(i=0; i<200; i+) fscanf(in,"%d,",&aai);fclose(in);writeDat()FILE *out;int i;clrscr();out=fopen("out.dat","w");for(i=0; i<10; i+)printf("i=%d,%dn",i+1,bbi);fprintf(out,"%dn",bbi);fclose(out);題目7(結(jié)構(gòu)體操作題)已知在文件IN.DAT中存有100個產(chǎn)品銷售記錄,每個產(chǎn)品銷售記錄由產(chǎn)品代碼dm(字符型4位),產(chǎn)品名稱mc(字符型10位),單價dj(整型),數(shù)量sl(整型),金額je(長整型)五部分組成。其中:金額=單價*數(shù)量計算得出。函數(shù)ReadDat()是讀取這100個銷售記錄并存入結(jié)構(gòu)數(shù)組sell中。請編制函數(shù)SortDat(),其功能要求:按產(chǎn)品代碼從大到小進行排列,若產(chǎn)品代碼相同,則按金額從大到小進行排列,最終排列結(jié)果仍存入結(jié)構(gòu)數(shù)組sell中,最后調(diào)用函數(shù)WriteDat()把結(jié)果輸出到文件OUT6.DAT中。 部分源程序存在文件prog1.c中。請勿改動主函數(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 struct char dm5; /*產(chǎn)品代碼*/ char mc11; /*產(chǎn)品名稱*/ int dj; /*單價*/ 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(strcmp(selli.dm,sellj.dm)<0|strcmp(selli.dm,sellj.dm)=0&&selli.je<sellj.je) 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+) 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); selli.je=(long)selli.dj*selli.sl; fclose(fp);void WriteDat(void) FILE *fp; int i; fp=fopen("OUT6.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);題目8(字符替換題)函數(shù)ReadDat()實現(xiàn)從文件ENG.IN中讀取一篇英文文章,存入到字符串數(shù)組xx中;請編制函數(shù)encryptChar(),按給定的替代關(guān)系對數(shù)組xx中的所有字符進行替代,仍存入數(shù)組xx的對應(yīng)的位置上,最后調(diào)用函數(shù)WriteDat()把結(jié)果xx輸出到文件PS1.DAT中。替代關(guān)系:f(p)=p*11 mod 256(p是數(shù)組中某一個字符的ASCII值,f(p)是計算后新字符的ASCII值),如果計算后f(p)值小于等于32或大于130,則該字符不變,否則將f(p)所對應(yīng)的字符進行替代。(注意中間變量用無符號整型),部分源程序存在文件prog1.c中。原始數(shù)據(jù)文件存放的格式是:每行的寬度均小于80個字符。請勿改動主函數(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 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>130) continue; else xxij=xxij*11%256;void main() clrscr(); if(ReadDat() printf("數(shù)據(jù)文件ENG.IN不能打開!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(p)*p=0; i+; maxline=i;fclose(fp);return 0;void WriteDat(void) FILE *fp; int i; fp=fopen("ps1.dat","w"); for(i=0;i<maxline;i+) printf("%sn",xxi); fprintf(fp,"%sn",xxi); fclose(fp);題目9(字符串排序題)函數(shù)ReadDat()實現(xiàn)從文件IN.DAT中讀取一篇英文文章存入到字符串數(shù)組xx中,請編制函數(shù)SortCharD(),其函數(shù)的功能是:以行為單位對字符按從大到小的順序進行排序,排序后的結(jié)果仍按行重新存入字符串數(shù)組xx中,最后調(diào)用函數(shù)writeDat()把結(jié)果xx輸出到文件OUT2.DAT中。 例:原文:dAe,BfC. CCbbAA 結(jié)果:fedCBA. bbCCAA 原始數(shù)據(jù)文件存放的格式是:每行的寬度均小于80個字符,含標點符號和空格。 部分源程序存在文件prog1.c中。 請勿改動主函數(shù)main()、讀數(shù)據(jù)函數(shù)ReadDat()和輸出數(shù)據(jù)函數(shù)writeDat()的內(nèi)容。#include <stdio.h>#include <string.h>#include <conio.h>char xx5080;int maxline=0;/*文章的總行數(shù)*/int ReadDat(void);void WriteDat(void);void SortCharD(void)int i,j,k,strl; char ch; for(i=0;i<maxline;i+) strl=strlen(xxi); for(j=0;j<strl-1;j+) for(k=j+1;k<strl;k+) if(xxij<xxik) ch=xxij; xxij=xxik; xxik=ch; void main() clrscr(); if(ReadDat() printf("數(shù)據(jù)文件IN.DAT不能打開!n007"); return; SortCharD(); WriteDat();int ReadDat(void) FILE *fp; int i=0; char *p; if(fp=fopen("IN.DAT","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("OUT2.DAT","w"); for(i=0;i<maxline;i+) printf("%sn",xxi); fprintf(fp,"%sn",xxi); fclose(fp);題目10(替換字符題)函數(shù)ReadDat()實現(xiàn)從文件IN.DAT中讀取一篇英文文章存入到字符串數(shù)組xx中,請編制函數(shù)ConvertCharA(),其函數(shù)的功能是:以行為單位把字符串中的所有小寫字母改寫成該字母的下一個字母,如果是字母z,則改寫成字母a。大寫字母仍為大寫字母,小寫字母仍為小寫字母,其他字符不變。把已處理的字符串仍按行重新存入字符串數(shù)組xx中,最后調(diào)用函數(shù)writeDat()把結(jié)果xx輸出到文件OUT1.DAT中。 例:原文:Adb.Bcdza abck.LLhj 結(jié)果:Aec.Bdeab bcdl.LLik 原始數(shù)據(jù)文件存放的格式是:每行的寬度均小于80個字符,含標點符號和空格。 部分源程序存在文件prog1.c中。 請勿改動主函數(shù)main()、讀數(shù)據(jù)函數(shù)ReadDat()和輸出數(shù)據(jù)函數(shù)writeDat()的內(nèi)容。#include <stdio.h>#include <string.h>#include <conio.h>char xx5080;int maxline=0;/*文章的總行數(shù)*/int ReadDat(void);void WriteDat(void);void ConvertCharA(void) int i,j; for(i=0;i<maxline;i+) for(j=0;j<strlen(xxi);j+)if(xxij='z') xxij='a' else if(xxij>='a'&&xxij<='y') xxij+=1; void main() clrscr(); if(ReadDat() printf("數(shù)據(jù)文件IN.DAT不能打開!n007"); return; ConvertCharA(); WriteDat();int ReadDat(void) FILE *fp; int i=0; char *p; if(fp=fopen("IN.DAT","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; clrscr(); fp=fopen("OUT1.DAT","w"); for(i=0;i<maxline;i+) printf("%sn",xxi); fprintf(fp,"%sn",xxi); fclose(fp);題目11(字符串字母移位題)程序prog1.c的功能是:把 s 字符串中的所有字母改寫成該字母的下一個字母,字母z改寫成字母a。要求大寫字母仍為大寫字母,小寫字母仍為小寫字母,其它字符不做改變。 請考生編寫函數(shù)chg(char *s)實現(xiàn)程序要求,最后調(diào)用函數(shù)readwriteDAT( )把結(jié)果輸出到文件bc1.out中。 例如:s 字符串中原有的內(nèi)容為:Mn.123Zxy,則調(diào)用該函數(shù)后,結(jié)果為:No.123Ayz。 注意:部分源程序存在文件prog1.c文件中。 請勿改動主函數(shù)main( )和輸出數(shù)據(jù)函數(shù)readwriteDAT()的內(nèi)容。#include <conio.h>#include <string.h>#include <stdio.h>#include <ctype.h>#define N 81void readwriteDAT();void chg(char *s)int I;for(I=0;I<strlen(s);I+) if(si='z'|si='Z') si-=25; else if(si>='a'&&si<='y'|si >='A'&&si<='Y') si+=1; main( ) char aN; clrscr(); printf("Enter a string : "); gets(a); printf("The original string is : "); puts(a); chg(a); printf("The string after modified : "); puts (a); readwriteDAT() ;void readwriteDAT() int i ; char aN ; FILE *rf, *wf ; rf = fopen("bc1.in", "r") ; wf = fopen("bc1.out", "w") ; for(i = 0 ; i < 50 ; i+) fscanf(rf, "%s", a) ; chg(a) ; fprintf(wf, "%sn", a) ; fclose(rf) ; fclose(wf) ;題目12(結(jié)構(gòu)體運算題題)已知在文件IN.DAT中存有100個產(chǎn)品銷售記錄,每個產(chǎn)品銷售記錄由產(chǎn)品代碼dm(字符型4位),產(chǎn)品名稱mc(字符型10位),單價dj(整型),數(shù)量sl(整型),金額je(長整型)五部分組成。其中:金額=單價*數(shù)量計算得出。函數(shù)ReadDat()是讀取這100個銷售記錄并存入結(jié)構(gòu)數(shù)組sell中。請編制函數(shù)SortDat(),其功能要求:按產(chǎn)品名稱從小到大進行排列,若產(chǎn)品名稱相等,則按金額從小到大進行排列,最終排列結(jié)果仍存入結(jié)構(gòu)數(shù)組sell中,最后調(diào)用函數(shù)WriteDat()把結(jié)果輸出到文件OUT5.DAT中。 部分源程序存在文件prog1.c中。請勿改動主函數(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 struct char dm5; /*產(chǎn)品代碼*/ char mc11; /*產(chǎn)品名稱*/ int dj; /*單價*/ 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(strcmp(selli.mc,sellj.mc)>0|strcmp(selli.mc,sellj.mc)=0&&selli.je>sellj.je) xy=selli;selli=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+) 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); selli.je=(long)selli.dj*selli.sl; fclose(fp);void WriteDat() FILE *fp; int i; fp=fopen("OUT5.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);題目13(結(jié)構(gòu)體運算題)已知在文件IN.DAT中存有100個產(chǎn)品銷售記錄,每個產(chǎn)品銷售記錄由產(chǎn)品代碼dm(字符型4位),產(chǎn)品名稱mc(字符型10位),單價dj(整型),數(shù)量sl(整型),金額je(長整型)五部分組成。其中:金額=單價*數(shù)量計算得出。函數(shù)ReadDat()是讀取這100個銷售記錄并存入結(jié)構(gòu)數(shù)組sell中。請編制函數(shù)SortDat(),其功能要求:按產(chǎn)品代碼從小到大進行排列,若產(chǎn)品代碼相等,則按金額從大到小進行排列,最終排列結(jié)果仍存入結(jié)構(gòu)數(shù)組sell中,最后調(diào)用函數(shù)WriteDat()把結(jié)果輸出到文件OUT9.DAT中。 部分源程序存在文件prog1.c中。請勿改動主函數(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 struct char dm5; /*產(chǎn)品代碼*/ char mc11; /*產(chǎn)品名稱*/ int dj; /*單價*/ 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(strcmp(selli.dm,sellj.dm)>0|strcmp(selli.dm,sellj.dm)=0&&selli.je<sellj.je) xy=selli;selli=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+) 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); selli.je=(long)selli.dj*selli.sl; fclose(fp);void WriteDat() FILE *fp; int i; fp=fopen("OUT9.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);題目14(整數(shù)統(tǒng)計排序題)已知數(shù)據(jù)文件IN.DAT中存有200個四位數(shù),并已調(diào)用讀函數(shù)readDat()把這些數(shù)存入數(shù)組a中,請考生編制一函數(shù)jsVal(),其功能是:依次從數(shù)組a中取出一個四位數(shù),如果該四位數(shù)連續(xù)大于該四位數(shù)以后的五個數(shù)且該數(shù)是奇數(shù)(該四位數(shù)以后不滿五個數(shù),則不統(tǒng)計),則統(tǒng)計出滿足此條件的個數(shù)cnt并把這些四位數(shù)按從小到大的順序存入數(shù)組b中,最后調(diào)用寫函數(shù)writeDat( )把結(jié)果cnt以及數(shù)組b中符合條件的四位數(shù)輸出到OUT.DAT文件中。 注意:部分源程序存在文件prog1.c中。 程序中已定義數(shù)組:a200,b200,已定義變量:cnt 請勿改動數(shù)據(jù)文件IN.DAT中的任何數(shù)據(jù)、主函數(shù)main()、讀函數(shù)readDat()和寫函數(shù)writeDat()的內(nèi)容。#include <stdio.h>#define MAX 200int aMAX, bMAX, cnt = 0 ;void jsVal()int i,j,flag; for(i=0;i<MAX-5;i+) for(j=i+1;j<=i+5;j+) if(ai>aj&&ai%2) flag=1; else flag=0;break; if(flag=1) bcnt+=ai; for(i=0;i<cnt-1;i+) for(j=i+1;j<cnt;j+) if(bi>bj) flag=bi;bi=bj;bj=flag;void readDat() int i ; FILE *fp ; fp = fopen("in.dat", "r") ; for(i = 0 ; i < MAX ; i+) fscanf(fp, "%d", &ai) ; fclose(fp) ;void main() int i ; readDat() ; jsVal() ; printf("滿足條件的數(shù)=%dn", cnt) ; for(i = 0 ; i < cnt ; i+) printf("%d ", bi) ; printf("n") ; writeDat() ;writeDat() FILE *fp ; int i ; fp = fopen("out.dat", "w") ; fprintf(fp, "%dn", cnt) ; for(i = 0 ; i < cnt ; i+) fprintf(fp, "%dn", bi) ; fclose(fp) ;題目15(整數(shù)各位數(shù)字運算排序題)已知數(shù)據(jù)文件IN.DAT中存有200個四位數(shù),并已調(diào)用讀函數(shù)readDat()把這些數(shù)存入數(shù)組a中,請考生編制一函數(shù)jsVal(),其功能是:若一個四位數(shù)的千位數(shù)字上的值小于等于百位數(shù)字上的值,百位數(shù)字上的值小于等于十位數(shù)字上的值,以及十位數(shù)字上的值小于等于個位數(shù)字上的值,并且原四位數(shù)是偶數(shù),則統(tǒng)計出滿足此條件的個數(shù)cnt并把這些四位數(shù)按從小到大的順序存入數(shù)組b中,最后調(diào)用寫函數(shù)writeDat()把結(jié)果cnt以及數(shù)組b中符合條件的四位數(shù)輸出到OUT.DAT文件中。 注意:部分源程序存在文件prog1.c中。 程序中已定義數(shù)組:a200,b200,已定義變量:cnt 請勿改動數(shù)據(jù)文件IN.DAT中的任何數(shù)據(jù)、主函數(shù)main()、讀函數(shù)readDat()和寫函數(shù)writeDat()的內(nèi)容。#include <stdio.h>#define MAX 200int aMAX, bMAX, cnt=0;void jsVal()int i,j; int qw,bw,sw,gw; for (i=0;i<MAX;i+) qw=ai/1000; bw=ai%1000/100; sw=ai%100/10; gw=ai%10; if(qw<=bw)&&(bw<=sw)&&(sw<=gw)&&(ai%2=0) bcnt+=ai; for(i=0;i<cnt-1;i+) for(j=i+1;j<cnt;j+) if (bi>bj) qw=bi;bi=bj;bj=qw;void readDat() int i ; FILE *fp ; fp = fopen("in.dat", "r") ; for(i = 0 ; i < MAX ; i+) fscanf(fp, "%d", &ai) ; fclose(fp) ;void main() int i ; readDat() ; jsVal() ; printf("滿足條件的

注意事項

本文(全國計算機等級考試 三級C語言上機題庫 上機100題)為本站會員(仙***)主動上傳,裝配圖網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對上載內(nèi)容本身不做任何修改或編輯。 若此文所含內(nèi)容侵犯了您的版權(quán)或隱私,請立即通知裝配圖網(wǎng)(點擊聯(lián)系客服),我們立即給予刪除!

溫馨提示:如果因為網(wǎng)速或其他原因下載失敗請重新下載,重復(fù)下載不扣分。




關(guān)于我們 - 網(wǎng)站聲明 - 網(wǎng)站地圖 - 資源地圖 - 友情鏈接 - 網(wǎng)站客服 - 聯(lián)系我們

copyright@ 2023-2025  zhuangpeitu.com 裝配圖網(wǎng)版權(quán)所有   聯(lián)系電話:18123376007

備案號:ICP2024067431-1 川公網(wǎng)安備51140202000466號


本站為文檔C2C交易模式,即用戶上傳的文檔直接被用戶下載,本站只是中間服務(wù)平臺,本站所有文檔下載所得的收益歸上傳人(含作者)所有。裝配圖網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對上載內(nèi)容本身不做任何修改或編輯。若文檔所含內(nèi)容侵犯了您的版權(quán)或隱私,請立即通知裝配圖網(wǎng),我們立即給予刪除!