在线现看午夜福利片|女人16久久免费视频|鲁丝片一区鲁丝片二区鲁丝|一区二区三区欧美在线

  1. 
    
    <b id="glvx9"></b>
        1. <blockquote id="glvx9"><meter id="glvx9"></meter></blockquote>
            首頁(yè) 考試吧論壇 Exam8視線 考試商城 網(wǎng)絡(luò)課程 模擬考試 考友錄 實(shí)用文檔 繽紛校園 英語(yǔ)學(xué)習(xí)
            2010考研 | 自學(xué)考試 | 成人高考 | 專 升 本 | 法律碩士 | MBA/MPA | 中 科 院
            四六級(jí) | 商務(wù)英語(yǔ) | 公共英語(yǔ) | 職稱日語(yǔ) | 職稱英語(yǔ) | 博思 | 口譯筆譯 | GRE GMAT | 日語(yǔ) | 托福
            雅思 | 專四專八 | 新概念 | 自考英語(yǔ) | 零起點(diǎn)英、、、韓語(yǔ) | 在職申碩英語(yǔ)
            在職攻碩英語(yǔ) | 成人英語(yǔ)三級(jí)
            等級(jí)考試 | 水平考試 | 微軟認(rèn)證 | 思科認(rèn)證 | Oracle認(rèn)證 | Linux認(rèn)證
            公務(wù)員 | 報(bào)關(guān)員 | 報(bào)檢員 | 外銷員 | 司法考試 | 導(dǎo)游考試 | 教師資格 | 國(guó)際商務(wù)師 | 跟單員
            單證員 | 物流師 | 價(jià)格鑒證師 | 銀行從業(yè)資格 | 證券從業(yè)資格 | 人力資源管理師 | 管理咨詢師
            期貨從業(yè)資格 | 社會(huì)工作者
            會(huì)計(jì)職稱 | 注會(huì)CPA | 經(jīng)濟(jì)師 | 統(tǒng)計(jì)師 | 注冊(cè)稅務(wù)師 | 評(píng)估師 | 精算師 | 高會(huì) | ACCA | 審計(jì)師
            法律顧問(wèn) | 會(huì)計(jì)證
            一級(jí)建造師 | 二級(jí)建造師 | 造價(jià)師 | 監(jiān)理師 | 安全師 | 咨詢師 | 結(jié)構(gòu)師 | 建筑師 | 安全評(píng)價(jià)師
            房地產(chǎn)估價(jià)師 | 土地估價(jià)師 | 設(shè)備監(jiān)理師 | 巖土工程師 | 質(zhì)量資格 | 房地產(chǎn)經(jīng)紀(jì)人 | 造價(jià)員
            投資項(xiàng)目管理 | 土地代理人 | 環(huán)保師 | 環(huán)境影響評(píng)價(jià) | 物業(yè)管理師 | 城市規(guī)劃師 | 公路監(jiān)理師
            公路造價(jià)工程師 | 招標(biāo)師
            執(zhí)業(yè)護(hù)士 | 執(zhí)業(yè)醫(yī)師 | 執(zhí)業(yè)藥師 | 衛(wèi)生資格

            1999年9月全國(guó)計(jì)算機(jī)等級(jí)考試四級(jí)機(jī)試試題及答案(已運(yùn)行通過(guò))

            1./*PROG1 已知在文件IN.DAT中存有若干個(gè)(個(gè)數(shù)<200)四位數(shù)字的正整數(shù),
            函數(shù)ReadDat()是讀取這若干個(gè)正整數(shù)并存入數(shù)組XX中。請(qǐng)編制函數(shù)CalValue(),
            其功能要求:1、求出這文件中共有多少個(gè)正整數(shù)totNum;2、求出這些數(shù)中的
            各位數(shù)字之和是偶數(shù)的數(shù)的個(gè)數(shù)totCnt,以及滿足此條件的這些數(shù)的算術(shù)平均
            值totpjZ,最后調(diào)用函數(shù)WriteDat()把所求的結(jié)果輸出到文件OUT2.DAT中。
            注意:部分部分源程序存放在PROG1.C中。
            請(qǐng)勿改動(dòng)主函數(shù)main(),讀數(shù)據(jù)函數(shù)ReacdDat()和輸出數(shù)據(jù)函數(shù)WriteDat()的內(nèi)容。*/
            #include <stdio.h>
            #include <conio.h>
            #define MAXNUM 200

            int xx[MAXNUM] ;
            int totNum = 0 ; /* 文件IN.DAT中共有多少個(gè)正整數(shù) */
            int totCnt = 0 ; /* 符合條件的正整數(shù)的個(gè)數(shù) */
            double totPjz = 0.0 ; /* 平均值 */

            int ReadDat(void) ;
            void WriteDat(void) ;

            void CalValue(void)
            { int i;
            int a,b,c,d;
            double sum=0;
            for (i=0;i<MAXNUM;i++)
            if (xx[i]>0)
            {
            totNum++;
            a=xx[i]/1000;
            b=xx[i]/100-a*10;
            c=xx[i]/10-a*100-b*10;
            d=xx[i]%10;
            if((a+b+c+d)%2==0)
            {totCnt++;
            sum=sum+xx[i];
            }
            }
            totPjz=sum/totCnt;
            }


            void main()
            {
            clrscr() ;
            if(ReadDat()) {
            printf("數(shù)據(jù)文件IN.DAT不能打開(kāi)!\007\n") ;
            return ;
            }
            CalValue() ;
            printf("文件IN.DAT中共有正整數(shù)=%d個(gè)\n", totNum) ;
            printf("符合條件的正整數(shù)的個(gè)數(shù)=%d個(gè)\n", totCnt) ;
            printf("平均值=%.2lf\n", totPjz) ;
            WriteDat() ;
            }

            int ReadDat(void)
            {
            FILE *fp ;
            int i = 0 ;

            if((fp = fopen("in.dat", "r")) == NULL) return 1 ;
            while(!feof(fp)) {
            fscanf(fp, "%d,", &xx[i++]) ;

            }
            fclose(fp) ;
            return 0 ;
            }

            void WriteDat(void)
            {
            FILE *fp ;

            fp = fopen("OUT2.DAT", "w") ;
            fprintf(fp, "%d\n%d\n%.2lf\n", totNum, totCnt, totPjz) ;
            fclose(fp) ;
            }

            2./*PROG2 已知在文件IN.DAT中存有若干個(gè)(個(gè)數(shù)<200)四位數(shù)字的正整數(shù),
            函數(shù)ReadDat()是讀取這若干個(gè)正整數(shù)并存入數(shù)組XX中。請(qǐng)編制函數(shù)CalValue(),
            其功能要求:1、求出這文件中共有多少個(gè)正整數(shù)totNum;2、求出這些數(shù)右移
            1位后,產(chǎn)生的新數(shù)是偶數(shù)的數(shù)的個(gè)數(shù)totCnt,以及滿足此條件的這些數(shù)(右移
            前的值)的算術(shù)平均值totpjZ,最后調(diào)用函數(shù)WriteDat()把所求的結(jié)果輸出到
            文件OUT4.DAT中。
            注意:部分部分源程序存放在PROG2.C中。
            請(qǐng)勿改動(dòng)主函數(shù)main(),讀數(shù)據(jù)函數(shù)ReacdDat()和輸出數(shù)據(jù)函數(shù)WriteDat()的內(nèi)容。*/
            #include <stdio.h>
            #include <conio.h>
            #define MAXNUM 200

            int xx[MAXNUM] ;
            int totNum = 0 ; /* 文件IN.DAT中共有多少個(gè)正整數(shù) */
            int totCnt = 0 ; /* 符合條件的正整數(shù)的個(gè)數(shù) */
            double totPjz = 0.0 ; /* 平均值 */

            int ReadDat(void) ;
            void WriteDat(void) ;

            void CalValue(void)
            { int i,s;
            double sum=0;
            for (i=0;i<MAXNUM;i++)
            if (xx[i]>0)
            { totNum++;
            s=xx[i];
            s=s>>1;
            if ((s%2)==0)
            {
            totCnt++;
            sum=sum+xx[i];
            }
            }
            totPjz=sum/totCnt;
            }

            void main()
            {
            clrscr() ;
            if(ReadDat()) {
            printf("數(shù)據(jù)文件IN.DAT不能打開(kāi)!\007\n") ;
            return ;
            }
            CalValue() ;
            printf("文件IN.DAT中共有正整數(shù)=%d個(gè)\n", totNum) ;
            printf("符合條件的正整數(shù)的個(gè)數(shù)=%d個(gè)\n", totCnt) ;
            printf("平均值=%.2lf\n", totPjz) ;
            WriteDat() ;
            }

            int ReadDat(void)
            {
            FILE *fp ;
            int i = 0 ;

            if((fp = fopen("in.dat", "r")) == NULL) return 1 ;
            while(!feof(fp)) {
            fscanf(fp, "%d,", &xx[i++]) ;
            }
            fclose(fp) ;
            return 0 ;
            }

            void WriteDat(void)
            {
            FILE *fp ;

            fp = fopen("OUT4.DAT", "w") ;
            fprintf(fp, "%d\n%d\n%.2lf\n", totNum, totCnt, totPjz) ;
            fclose(fp) ;
            }

            3./*PROG3 已知在文件IN.DAT中存有若干個(gè)(個(gè)數(shù)<200)四位數(shù)字的正整數(shù),
            函數(shù)ReadDat()是讀取這若干個(gè)正整數(shù)并存入數(shù)組XX中。請(qǐng)編制函數(shù)CalValue(),
            其功能要求:1、求出這文件中共有多少個(gè)正整數(shù)totNum;2、求出這些數(shù)中的
            個(gè)位數(shù)位置上的數(shù)字是3.6和9的數(shù)的數(shù)的個(gè)數(shù)totCnt,以及滿足此條件的這些
            數(shù)的算術(shù)平均值totpjZ,最后調(diào)用函數(shù)WriteDat()把所求的結(jié)果輸出到文件
            OUT5.DAT中。
            注意:部分部分源程序存放在PROG3.C中。
            請(qǐng)勿改動(dòng)主函數(shù)main(),讀數(shù)據(jù)函數(shù)ReacdDat()和輸出數(shù)據(jù)函數(shù)WriteDat()的內(nèi)容。*/
            #include <stdio.h>
            #include <conio.h>
            #define MAXNUM 200

            int xx[MAXNUM] ;
            int totNum = 0 ; /* 文件IN.DAT中共有多少個(gè)正整數(shù) */
            int totCnt = 0 ; /* 符合條件的正整數(shù)的個(gè)數(shù) */
            double totPjz = 0.0 ; /* 平均值 */

            int ReadDat(void) ;
            void WriteDat(void) ;

            void CalValue(void)
            { int i,gw;
            double sum=0;
            for(i=0;i<MAXNUM;i++)
            if (xx[i]>0)
            { totNum++;
            gw=xx[i]%10;
            if((gw==3)||(gw==6)||(gw==9))
            {
            totCnt++;
            sum=sum+xx[i];
            }
            }
            totPjz=sum/totCnt;
            }

            void main()
            {
            clrscr() ;
            if(ReadDat()) {
            printf("數(shù)據(jù)文件IN.DAT不能打開(kāi)!\007\n") ;
            return ;
            }
            CalValue() ;
            printf("文件IN.DAT中共有正整數(shù)=%d個(gè)\n", totNum) ;
            printf("符合條件的正整數(shù)的個(gè)數(shù)=%d個(gè)\n", totCnt) ;
            printf("平均值=%.2lf\n", totPjz) ;
            WriteDat() ;
            }

            int ReadDat(void)
            {
            FILE *fp ;
            int i = 0 ;

            if((fp = fopen("in.dat", "r")) == NULL) return 1 ;
            while(!feof(fp)) {
            fscanf(fp, "%d,", &xx[i++]) ;
            }
            fclose(fp) ;
            return 0 ;
            }

            void WriteDat(void)
            {
            FILE *fp ;

            fp = fopen("OUT5.DAT", "w") ;
            fprintf(fp, "%d\n%d\n%.2lf\n", totNum, totCnt, totPjz) ;
            fclose(fp) ;
            }

            4./*PROG4 已知在文件IN.DAT中存有若干個(gè)(個(gè)數(shù)<200)四位數(shù)字的正整數(shù),
            函數(shù)ReadDat()是讀取這若干個(gè)正整數(shù)并存入數(shù)組XX中。請(qǐng)編制函數(shù)CalValue(),
            其功能要求:1、求出這文件中共有多少個(gè)正整數(shù)totNum;2、求出這些數(shù)中的
            千位數(shù)位置上的數(shù)字大于個(gè)位數(shù)位置上的數(shù)字的數(shù)的個(gè)數(shù)totCnt,以及滿足此
            條件的這些數(shù)的算術(shù)平均值totpjZ,最后調(diào)用函數(shù)WriteDat()把所求的結(jié)果輸
            出到文件OUT8.DAT中。
            注意:部分部分源程序存放在PROG4.C中。
            請(qǐng)勿改動(dòng)主函數(shù)main(),讀數(shù)據(jù)函數(shù)ReacdDat()和輸出數(shù)據(jù)函數(shù)WriteDat()的內(nèi)容。*/
            #include <stdio.h>
            #include <conio.h>
            #define MAXNUM 200

            int xx[MAXNUM] ;
            int totNum = 0 ; /* 文件IN.DAT中共有多少個(gè)正整數(shù) */
            int totCnt = 0 ; /* 符合條件的正整數(shù)的個(gè)數(shù) */
            double totPjz = 0.0 ; /* 平均值 */

            int ReadDat(void) ;
            void WriteDat(void) ;

            void CalValue(void)
            { int i;
            int qw,gw;
            double sum=0;
            for (i=0;i<MAXNUM;i++)
            if (xx[i]>0)
            {
            totNum++;
            qw=xx[i]/1000;
            gw=xx[i]%10;
            if(qw>gw)
            {
            totCnt++;
            sum=sum+xx[i];
            }
            }
            totPjz=sum/totCnt;

            }

            void main()
            {
            clrscr() ;
            if(ReadDat()) {
            printf("數(shù)據(jù)文件IN.DAT不能打開(kāi)!\007\n") ;
            return ;
            }
            CalValue() ;
            printf("文件IN.DAT中共有正整數(shù)=%d個(gè)\n", totNum) ;
            printf("符合條件的正整數(shù)的個(gè)數(shù)=%d個(gè)\n", totCnt) ;
            printf("平均值=%.2lf\n", totPjz) ;
            WriteDat() ;
            }

            int ReadDat(void)
            {
            FILE *fp ;
            int i = 0 ;

            if((fp = fopen("in.dat", "r")) == NULL) return 1 ;
            while(!feof(fp)) {
            fscanf(fp, "%d,", &xx[i++]) ;
            }
            fclose(fp) ;
            return 0 ;
            }

            void WriteDat(void)
            {
            FILE *fp ;

            fp = fopen("OUT8.DAT", "w") ;
            fprintf(fp, "%d\n%d\n%.2lf\n", totNum, totCnt, totPjz) ;
            fclose(fp) ;
            }

            5./*PROG5 已知在文件IN.DAT中存有若干個(gè)(個(gè)數(shù)<200)四位數(shù)字的正整數(shù),
            函數(shù)ReadDat()是讀取這若干個(gè)正整數(shù)并存入數(shù)組XX中。請(qǐng)編制函數(shù)CalValue(),
            其功能要求:1、求出這文件中共有多少個(gè)正整數(shù)totNum;2、求出這些數(shù)中的
            百位數(shù)位置上的數(shù)字是1、5和7的數(shù)的個(gè)數(shù)totCnt,以及滿足此條件的這些數(shù)的
            算術(shù)平均值totpjZ,最后調(diào)用函數(shù)WriteDat()把所求的結(jié)果輸出到文件OUT7.DAT中。
            注意:部分部分源程序存放在PROG5.C中。
            請(qǐng)勿改動(dòng)主函數(shù)main(),讀數(shù)據(jù)函數(shù)ReacdDat()和輸出數(shù)據(jù)函數(shù)WriteDat()的內(nèi)容。*/
            #include <stdio.h>
            #include <conio.h>
            #define MAXNUM 200

            int xx[MAXNUM] ;
            int totNum = 0 ; /* 文件IN.DAT中共有多少個(gè)正整數(shù) */
            int totCnt = 0 ; /* 符合條件的正整數(shù)的個(gè)數(shù) */
            double totPjz = 0.0 ; /* 平均值 */

            int ReadDat(void) ;
            void WriteDat(void) ;

            void CalValue(void)
            { int i;
            int bw,qw;
            double sum=0;
            for (i=0;i<MAXNUM;i++)
            if(xx[i]>0)
            {totNum++;
            qw=xx[i]/1000;
            bw=xx[i]/100-qw*10;
            if((bw==1)||(bw==5)||(bw==7))
            {totCnt++;
            sum=sum+xx[i];
            }
            }
            totPjz=sum/totCnt;
            }

            void main()
            {
            clrscr() ;
            if(ReadDat()) {
            printf("數(shù)據(jù)文件IN.DAT不能打開(kāi)!\007\n") ;
            return ;
            }
            CalValue() ;
            printf("文件IN.DAT中共有正整數(shù)=%d個(gè)\n", totNum) ;
            printf("符合條件的正整數(shù)的個(gè)數(shù)=%d個(gè)\n", totCnt) ;
            printf("平均值=%.2lf\n", totPjz) ;
            WriteDat() ;
            }

            int ReadDat(void)
            {
            FILE *fp ;
            int i = 0 ;

            if((fp = fopen("in.dat", "r")) == NULL) return 1 ;
            while(!feof(fp)) {
            fscanf(fp, "%d,", &xx[i++]) ;
            }
            fclose(fp) ;
            return 0 ;
            }

            void WriteDat(void)
            {
            FILE *fp ;

            fp = fopen("OUT7.DAT", "w") ;
            fprintf(fp, "%d\n%d\n%.2lf\n", totNum, totCnt, totPjz) ;
            fclose(fp) ;
            }

            6./*PROG6 已知在文件IN.DAT中存有若干個(gè)(個(gè)數(shù)<200)四位數(shù)字的正整數(shù),
            函數(shù)ReadDat()是讀取這若干個(gè)正整數(shù)并存入數(shù)組XX中。請(qǐng)編制函數(shù)CalValue(),
            其功能要求:1、求出這文件中共有多少個(gè)正整數(shù)totNum;2、求出這些數(shù)右移1
            位后,產(chǎn)生的新數(shù)是奇數(shù)的數(shù)的個(gè)數(shù)totCnt,以及滿足此條件的這些數(shù)(右移前
            的值)的算術(shù)平均值totpjZ,最后調(diào)用函數(shù)WriteDat()把所求的結(jié)果輸出到文件
            OUT3.DAT中。
            注意:部分部分源程序存放在PROG6.C中。
            請(qǐng)勿改動(dòng)主函數(shù)main(),讀數(shù)據(jù)函數(shù)ReacdDat()和輸出數(shù)據(jù)函數(shù)WriteDat()的內(nèi)容。*/
            #include <stdio.h>
            #include <conio.h>
            #define MAXNUM 200

            int xx[MAXNUM] ;
            int totNum = 0 ; /* 文件IN.DAT中共有多少個(gè)正整數(shù) */
            int totCnt = 0 ; /* 符合條件的正整數(shù)的個(gè)數(shù) */
            double totPjz = 0.0 ; /* 平均值 */

            int ReadDat(void) ;
            void WriteDat(void) ;

            void CalValue(void)
            {int i,s;
            double sum=0;
            for (i=0;i<MAXNUM;i++)
            if (xx[i]>0)
            {
            totNum++;
            s=xx[i];
            s=s>>1;
            if((s%2)==0)
            {
            totCnt++;
            sum=sum+xx[i];
            }
            }
            totPjz=sum/totCnt;

            }

            void main()
            {
            clrscr() ;
            if(ReadDat()) {
            printf("數(shù)據(jù)文件IN.DAT不能打開(kāi)!\007\n") ;
            return ;
            }
            CalValue() ;
            printf("文件IN.DAT中共有正整數(shù)=%d個(gè)\n", totNum) ;
            printf("符合條件的正整數(shù)的個(gè)數(shù)=%d個(gè)\n", totCnt) ;
            printf("平均值=%.2lf\n", totPjz) ;
            WriteDat() ;
            }

            int ReadDat(void)
            {
            FILE *fp ;
            int i = 0 ;

            if((fp = fopen("in.dat", "r")) == NULL) return 1 ;
            while(!feof(fp)) {
            fscanf(fp, "%d,", &xx[i++]) ;
            }
            fclose(fp) ;
            return 0 ;
            }

            void WriteDat(void)
            {
            FILE *fp ;

            fp = fopen("OUT3.DAT", "w") ;
            fprintf(fp, "%d\n%d\n%.2lf\n", totNum, totCnt, totPjz) ;
            fclose(fp) ;
            }

            7./*PROG7 已知在文件IN.DAT中存有若干個(gè)(個(gè)數(shù)<200)四位數(shù)字的正整數(shù),
            函數(shù)ReadDat()是讀取這若干個(gè)正整數(shù)并存入數(shù)組XX中。請(qǐng)編制函數(shù)CalValue(),
            其功能要求:1、求出這文件中共有多少個(gè)正整數(shù)totNum;2、求出這些數(shù)中的
            百位數(shù)位置上的數(shù)字小于十位數(shù)位置上的數(shù)字的數(shù)的個(gè)數(shù)totCnt,以及滿足此
            條件的這些數(shù)的算術(shù)平均值totpjZ,最后調(diào)用函數(shù)WriteDat()把所求的結(jié)果輸
            出到文件OUT9.DAT中。
            注意:部分部分源程序存放在PROG7.C中。
            請(qǐng)勿改動(dòng)主函數(shù)main(),讀數(shù)據(jù)函數(shù)ReacdDat()和輸出數(shù)據(jù)函數(shù)WriteDat()的內(nèi)容。*/
            #include <stdio.h>
            #include <conio.h>
            #define MAXNUM 200

            int xx[MAXNUM] ;
            int totNum = 0 ; /* 文件IN.DAT中共有多少個(gè)正整數(shù) */
            int totCnt = 0 ; /* 符合條件的正整數(shù)的個(gè)數(shù) */
            double totPjz = 0.0 ; /* 平均值 */

            int ReadDat(void) ;
            void WriteDat(void) ;

            void CalValue(void)
            {int qw,bw,sw;
            int i;
            double sum=0;
            for (i=0;i<MAXNUM;i++)
            if (xx[i]>0)
            {
            totNum++;
            qw=xx[i]/1000;
            bw=xx[i]/100-qw*10;
            sw=xx[i]/10-qw*100-bw*10;
            if (bw<sw)
            {
            totCnt++;
            sum+=xx[i];
            }
            }
            totPjz=sum/totCnt;
            }

            void main()
            {
            clrscr() ;
            if(ReadDat()) {
            printf("數(shù)據(jù)文件IN.DAT不能打開(kāi)!\007\n") ;
            return ;
            }
            CalValue() ;
            printf("文件IN.DAT中共有正整數(shù)=%d個(gè)\n", totNum) ;
            printf("符合條件的正整數(shù)的個(gè)數(shù)=%d個(gè)\n", totCnt) ;
            printf("平均值=%.2lf\n", totPjz) ;
            WriteDat() ;
            }

            int ReadDat(void)
            {
            FILE *fp ;
            int i = 0 ;

            if((fp = fopen("in.dat", "r")) == NULL) return 1 ;
            while(!feof(fp)) {
            fscanf(fp, "%d,", &xx[i++]) ;
            }
            fclose(fp) ;
            return 0 ;
            }

            void WriteDat(void)
            {
            FILE *fp ;

            fp = fopen("OUT9.DAT", "w") ;
            fprintf(fp, "%d\n%d\n%.2lf\n", totNum, totCnt, totPjz) ;
            fclose(fp) ;
            }

            8./*PROG8 已知在文件IN.DAT中存有若干個(gè)(個(gè)數(shù)<200)四位數(shù)字的正整數(shù),
            函數(shù)ReadDat()是讀取這若干個(gè)正整數(shù)并存入數(shù)組XX中。請(qǐng)編制函數(shù)CalValue(),
            其功能要求:1、求出這文件中共有多少個(gè)正整數(shù)totNum;2、求出這些數(shù)中的
            十位數(shù)位置上的數(shù)字是2、4和8的數(shù)的個(gè)數(shù)totCnt,以及滿足此條件的這些數(shù)的
            算術(shù)平均值totpjZ,最后調(diào)用函數(shù)WriteDat()把所求的結(jié)果輸出到文件OUT6.DAT中。
            注意:部分部分源程序存放在PROG8.C中。
            請(qǐng)勿改動(dòng)主函數(shù)main(),讀數(shù)據(jù)函數(shù)ReacdDat()和輸出數(shù)據(jù)函數(shù)WriteDat()的內(nèi)容。*/
            #include <stdio.h>
            #include <conio.h>
            #define MAXNUM 200

            int xx[MAXNUM] ;
            int totNum = 0 ; /* 文件IN.DAT中共有多少個(gè)正整數(shù) */
            int totCnt = 0 ; /* 符合條件的正整數(shù)的個(gè)數(shù) */
            double totPjz = 0.0 ; /* 平均值 */

            int ReadDat(void) ;
            void WriteDat(void) ;

            void CalValue(void)
            { int i,qw,bw,sw;
            double sum=0;
            for (i=0;i<MAXNUM;i++)
            if (xx[i]>0)
            {
            totNum++;
            qw=xx[i]/1000;
            bw=xx[i]/100-qw*10;
            sw=xx[i]/10-qw*100-bw*10;
            if ((sw==2)||(sw==4)||(sw==8))
            {
            totCnt++;
            sum=sum+xx[i];
            }
            }
            totPjz = sum / totCnt;
            }

            void main()
            {
            clrscr() ;
            if(ReadDat()) {
            printf("數(shù)據(jù)文件IN.DAT不能打開(kāi)!\007\n") ;
            return ;
            }
            CalValue() ;
            printf("文件IN.DAT中共有正整數(shù)=%d個(gè)\n", totNum) ;
            printf("符合條件的正整數(shù)的個(gè)數(shù)=%d個(gè)\n", totCnt) ;
            printf("平均值=%.2lf\n", totPjz) ;
            WriteDat() ;
            }

            int ReadDat(void)
            {
            FILE *fp ;
            int i = 0 ;

            if((fp = fopen("in.dat", "r")) == NULL) return 1 ;
            while(!feof(fp)) {
            fscanf(fp, "%d,", &xx[i++]) ;
            }
            fclose(fp) ;
            return 0 ;
            }

            void WriteDat(void)
            {
            FILE *fp ;

            fp = fopen("OUT6.DAT", "w") ;
            fprintf(fp, "%d\n%d\n%.2lf\n", totNum, totCnt, totPjz) ;
            fclose(fp) ;
            }

            9./*PROG9 已知在文件IN.DAT中存有若干個(gè)(個(gè)數(shù)<200)四位數(shù)字的正整數(shù),
            函數(shù)ReadDat()是讀取這若干個(gè)正整數(shù)并存入數(shù)組XX中。請(qǐng)編制函數(shù)CalValue(),
            其功能要求:1、求出這文件中共有多少個(gè)正整數(shù)totNum;2、求出這些數(shù)中的
            千位數(shù)位置上的數(shù)字與十位數(shù)位置上的數(shù)字均為奇數(shù)的數(shù)的個(gè)數(shù)totCnt,以及
            滿足此條件的這些數(shù)的算術(shù)平均值totpjZ,最后調(diào)用函數(shù)WriteDat()把所求的
            結(jié)果輸出到文件OUT10.DAT中。
            注意:部分部分源程序存放在PROG9.C中。
            請(qǐng)勿改動(dòng)主函數(shù)main(),讀數(shù)據(jù)函數(shù)ReacdDat()和輸出數(shù)據(jù)函數(shù)WriteDat()的內(nèi)容。*/
            #include <stdio.h>
            #include <conio.h>
            #define MAXNUM 200

            int xx[MAXNUM] ;
            int totNum = 0 ; /* 文件IN.DAT中共有多少個(gè)正整數(shù) */
            int totCnt = 0 ; /* 符合條件的正整數(shù)的個(gè)數(shù) */
            double totPjz = 0.0 ; /* 平均值 */

            int ReadDat(void) ;
            void WriteDat(void) ;

            void CalValue(void)
            { int i,qw,bw,sw;
            double sum=0;
            for (i=0;i<MAXNUM;i++)
            if (xx[i]>0)
            {
            totNum++;
            qw=xx[i]/1000;
            bw=xx[i]/100-qw*10;
            sw=xx[i]/10-qw*100-bw*10;
            if (((qw%2)==0) && ((sw%2)==0))
            {
            totCnt++;
            sum=sum+xx[i];
            }
            }
            totPjz = sum / totCnt;
            }

            void main()
            {
            clrscr() ;
            if(ReadDat()) {
            printf("數(shù)據(jù)文件IN.DAT不能打開(kāi)!\007\n") ;
            return ;
            }
            CalValue() ;
            printf("文件IN.DAT中共有正整數(shù)=%d個(gè)\n", totNum) ;
            printf("符合條件的正整數(shù)的個(gè)數(shù)=%d個(gè)\n", totCnt) ;
            printf("平均值=%.2lf\n", totPjz) ;
            WriteDat() ;
            }

            int ReadDat(void)
            {
            FILE *fp ;
            int i = 0 ;

            if((fp = fopen("in.dat", "r")) == NULL) return 1 ;
            while(!feof(fp)) {
            fscanf(fp, "%d,", &xx[i++]) ;
            }
            fclose(fp) ;
            return 0 ;
            }

            void WriteDat(void)
            {
            FILE *fp ;

            fp = fopen("OUT10.DAT", "w") ;
            fprintf(fp, "%d\n%d\n%.2lf\n", totNum, totCnt, totPjz) ;
            fclose(fp) ;
            }

            10./*PROG10 已知在文件IN.DAT中存有若干個(gè)(個(gè)數(shù)<200)四位數(shù)字的正整數(shù),
            函數(shù)ReadDat()是讀取這若干個(gè)正整數(shù)并存入數(shù)組XX中。請(qǐng)編制函數(shù)CalValue(),
            其功能要求:1、求出這文件中共有多少個(gè)正整數(shù)totNum;2、求出這些數(shù)中的各
            位數(shù)字之和是奇數(shù)的數(shù)的個(gè)數(shù)totCnt,以及滿足此條件的這些數(shù)的算術(shù)平均值
            totpjZ,最后調(diào)用函數(shù)WriteDat()把所求的結(jié)果輸出到文件OUT1.DAT中。
            注意:部分部分源程序存放在PROG10.C中。
            請(qǐng)勿改動(dòng)主函數(shù)main(),讀數(shù)據(jù)函數(shù)ReacdDat()和輸出數(shù)據(jù)函數(shù)WriteDat()的內(nèi)容。*/
            #include <stdio.h>
            #include <conio.h>
            #define MAXNUM 200

            int xx[MAXNUM] ;
            int totNum = 0 ; /* 文件IN.DAT中共有多少個(gè)正整數(shù) */
            int totCnt = 0 ; /* 符合條件的正整數(shù)的個(gè)數(shù) */
            double totPjz = 0.0 ; /* 平均值 */

            int ReadDat(void) ;
            void WriteDat(void) ;

            void CalValue(void)
            { int i;
            int qw,bw,sw,gw;
            double sum=0;
            for ( i=0 ; i<MAXNUM; i++)
            if (xx[i] > 0)
            {
            totNum ++ ;
            qw = xx[i] / 1000;
            bw = xx[i] / 100 - qw * 10;
            sw = xx[i] / 10 - qw * 100- bw * 10;
            gw = xx[i] % 10;
            if ( ( (qw+bw+sw+gw) % 2)!=0)
            {
            totCnt ++ ;
            sum = sum + xx[i];
            }
            }
            totPjz = sum / totCnt;

            }

            void main()
            {
            clrscr() ;
            if(ReadDat()) {
            printf("數(shù)據(jù)文件IN.DAT不能打開(kāi)!\007\n") ;
            return ;
            }
            CalValue() ;
            printf("文件IN.DAT中共有正整數(shù)=%d個(gè)\n", totNum) ;
            printf("符合條件的正整數(shù)的個(gè)數(shù)=%d個(gè)\n", totCnt) ;
            printf("平均值=%.2lf\n", totPjz) ;
            WriteDat() ;
            }

            int ReadDat(void)
            {
            FILE *fp ;
            int i = 0 ;

            if((fp = fopen("in.dat", "r")) == NULL) return 1 ;
            while(!feof(fp)) {
            fscanf(fp, "%d,", &xx[i++]) ;
            }
            fclose(fp) ;
            return 0 ;
            }

            void WriteDat(void)
            {
            FILE *fp ;

            fp = fopen("OUT1.DAT", "w") ;
            fprintf(fp, "%d\n%d\n%.2lf\n", totNum, totCnt, totPjz) ;
            fclose(fp) ;
            }                      

                      2000年9月全真試題
            1./* 程序PROG1.C的功能是:選出100至1000之間所有個(gè)位數(shù)字與十位數(shù)字之和
            被10除所得余數(shù)恰是百位數(shù)字的素?cái)?shù)(如293)。計(jì)算并輸出上述這些素?cái)?shù)的個(gè)
            數(shù)cnt以及這些素?cái)?shù)值的和sum。
            請(qǐng)考生編寫(xiě)函數(shù)countValue( )實(shí)現(xiàn)程序的要求,最后調(diào)用函數(shù)writeDAT( )把
            結(jié)果cnt和sum輸出到文件out6.DAT中。
            注意:部分源程序存放在PROG1.C中。
            請(qǐng)勿改動(dòng)主函數(shù)main( )和輸出數(shù)據(jù)函數(shù)writeDAT( )的內(nèi)容。 */
            #include <stdio.h>
            int cnt, sum ;

            void countValue()
            {

            }

            void main()
            {
            cnt = sum = 0 ;

            countValue() ;
            printf("素?cái)?shù)的個(gè)數(shù)=%d\n", cnt) ;
            printf("滿足條件素?cái)?shù)值的和=%d", sum) ;
            writeDAT() ;
            }

            writeDAT()
            {
            FILE *fp ;

            fp = fopen("OUT6.DAT", "w") ;
            fprintf(fp, "%d\n%d\n", cnt, sum) ;
            fclose(fp) ;
            }


            2. /* 編寫(xiě)函數(shù)sumValue( ),它的功能是:計(jì)算正整數(shù)n的所有因子(1和n除外)之
            和作為函數(shù)值返回。
            例如:n=20時(shí),函數(shù)值為21。
            函數(shù)ReadWrite( )是實(shí)現(xiàn)從文件in9.dat中讀取兩個(gè)字符串,并調(diào)用函數(shù)
            sumValue(),最后把結(jié)果輸出到文件out9.dat中。
            注意:部分源程序存在文件PROG1.C中,請(qǐng)勿改動(dòng)主函數(shù)main()和其它函數(shù)
            中的任何內(nèi)容,僅在函數(shù)sumValue()的花括號(hào)中填入你編寫(xiě)的若干語(yǔ)句。 */
            #include <conio.h>
            #include <stdio.h>
            int sumValue(int n)
            {

            }

            main()
            { clrscr() ;
            printf("%d\n", sumValue(20)) ;
            ReadWrite() ;
            }

            ReadWrite()
            {
            FILE *fp, *wf ;
            int i, n, s ;

            fp = fopen("in9.dat","r") ;
            if(fp == NULL) {
            printf("數(shù)據(jù)文件in9.dat不存在!") ;
            return ;
            }
            wf = fopen("out9.dat","w") ;
            for(i = 0 ; i < 10 ; i++) {
            fscanf(fp, "%d", &n) ;
            s = sumValue(n) ;
            fprintf(wf, "%d\n", s) ;
            }
            fclose(fp) ;
            fclose(wf) ;
            }

            3./* 請(qǐng)編寫(xiě)一個(gè)函數(shù)changeStr(char *s),函數(shù)的功能是把s串中所有的字
            母改寫(xiě)成該字母的下一個(gè)字母,字母z改寫(xiě)成字母a。大寫(xiě)仍為大寫(xiě)字母,
            小寫(xiě)字母仍為小寫(xiě)字母,其它的字符不變。
            函數(shù)ReadWrite()實(shí)現(xiàn)從文件in2.dat中讀取兩個(gè)字符串,并調(diào)用函
            數(shù)changestr(),最后把結(jié)果輸出到文件out2.dat中。
            注意:部分源程序存在文件PROG1.C中。請(qǐng)勿改動(dòng)主函數(shù)main()和其
            它函數(shù)中的任何內(nèi)容,僅在函數(shù)changeStr()的花括號(hào)中填入你編寫(xiě)的若干語(yǔ)名。*/
            #include <conio.h>
            #include <string.h>
            #include <stdio.h>
            #include <ctype.h>
            #define N 81
            changeStr ( char *s )
            {

            }

            main( )
            {
            char a[N] ;
            clrscr( ) ;
            printf ( "Enter a string : " ) ; gets ( a ) ;
            printf ( "The original string is : " ) ; puts( a ) ;
            changeStr ( a ) ;
            printf ( "The string after modified : ") ;
            puts ( a ) ;
            ReadWrite( ) ;
            }

            ReadWrite( )
            {
            int i ;
            char a[N] ;
            FILE *rf, *wf ;

            rf = fopen("in2.dat", "r") ;
            wf = fopen("out2.dat", "w") ;
            for(i = 0 ; i < 10 ; i++) {
            fscanf(rf, "%s", a) ;
            changeStr(a) ;
            fprintf(wf, "%s\n", a) ;
            }
            fclose(rf) ;
            fclose(wf) ;
            }

            4./* 程序PROG1.C的功能是:利用以下所示的簡(jiǎn)單迭代方法求方程:
            cos(x)-x=0的一個(gè)實(shí)根。
            Xn+1=cos(Xn)
            迭代步驟如下:
            (1) 取x1初步值為0.0;
            (2) x0=x1,把x1,把x1的值賦給x0;
            (3) x1=cos(x0),求出一個(gè)新的x1;
            (4) 若x0-x1的絕對(duì)值小于0.000001,執(zhí)行步驟(5),否則執(zhí)行步驟(2);
            (5) 所求x1就是方程cos(x)-x=0的一個(gè)實(shí)根,作為函數(shù)值返回。
            請(qǐng)編寫(xiě)函數(shù)countValue()實(shí)現(xiàn)程序的要求,最后調(diào)用函數(shù)writeDAT()把
            結(jié)果輸出到文件out4.dat中。
            注意:部分源程序存在文件PROG1.C中,請(qǐng)勿改動(dòng)主函數(shù)main()和輸出數(shù)
            據(jù)函數(shù)WriteDAT()的內(nèi)容。 */
            #include <conio.h>
            #include <math.h>
            #include <stdio.h>
            float countValue()
            {

            }

            main()
            {
            clrscr();
            printf("實(shí)根=%f\n", countValue());
            printf(" %f\n",cos(countValue())-countValue());
            writeDAT();
            }

            writeDAT()
            {
            FILE *wf ;

            wf=fopen("out4.dat","w") ;
            fprintf(wf, "%f\n", countValue()) ;
            fclose(wf) ;
            }

            5./* 已知在文件IN.DAT中存有若干個(gè)(個(gè)數(shù)<200)四位數(shù)字的正整數(shù),
            函數(shù)ReadDAT()讀取這些正整數(shù)并存入數(shù)組xx中。
            請(qǐng)編制函數(shù)CalValue()其功能要求是:1.求出這個(gè)文件中共有多
            少個(gè)正整數(shù)totNum;2.求出這些數(shù)中的各位數(shù)字之和是奇數(shù)的數(shù)的個(gè)
            數(shù)totCnt,以及不滿足此條件的所有數(shù)的算術(shù)平均值totPjz,最后調(diào)
            用函數(shù)WriteDAT()把所求的結(jié)果輸出到文件OUT8.DAT中。
            注意:部分源程序存放在PROG1.C中。
            請(qǐng)勿改動(dòng)主函數(shù)main(),讀數(shù)據(jù)函數(shù)ReadDAT()和輸出數(shù)據(jù)函數(shù)
            WriteDAT()的內(nèi)容。 */
            #include <stdio.h>
            #include <conio.h>
            #define MAXNUM 200

            int xx[MAXNUM] ;
            int totNum = 0 ; /* 文件IN.DAT中共有多少個(gè)正整數(shù) */
            int totCnt = 0 ; /* 符合條件的正整數(shù)的個(gè)數(shù) */
            double totPjz = 0.0 ; /* 平均值 */

            int ReadDat(void) ;
            void WriteDat(void) ;

            void CalValue(void)
            {

            }

            void main()
            {
            clrscr() ;
            if(ReadDat()) {
            printf("數(shù)據(jù)文件IN.DAT不能打開(kāi)!\007\n") ;
            return ;
            }
            CalValue() ;
            printf("文件IN.DAT中共有正整數(shù)=%d個(gè)\n", totNum) ;
            printf("符合條件的正整數(shù)的個(gè)數(shù)=%d個(gè)\n", totCnt) ;
            printf("平均值=%.2lf\n", totPjz) ;
            WriteDat() ;
            }

            int ReadDat(void)
            {
            FILE *fp ;
            int i = 0 ;

            if((fp = fopen("in.dat", "r")) == NULL) return 1 ;
            while(!feof(fp)) {
            fscanf(fp, "%d,", &xx[i++]) ;
            }
            fclose(fp) ;
            return 0 ;
            }

            void WriteDat(void)
            {
            FILE *fp ;

            fp = fopen("OUT8.DAT", "w") ;
            fprintf(fp, "%d\n%d\n%.2lf\n", totNum, totCnt, totPjz) ;
            fclose(fp) ;
            }

            6./* 編寫(xiě)一個(gè)函數(shù)findstr(),該函數(shù)統(tǒng)計(jì)一個(gè)長(zhǎng)度為2的子字符串在另一個(gè)
            字符串中出現(xiàn)的次數(shù)。例如,假定輸入的字符串為“asd asasdfg asd as
            zx67 asd mklo”,子字符串為“as”,則輸出6。
            函數(shù)ReadWrite()實(shí)現(xiàn)從文件in1.dat中讀取兩個(gè)字符串,并調(diào)用函數(shù)
            findStr(),最后把結(jié)果輸出到文件out1.dat中。
            注意:部分源程序存在文件PROG1.C中。請(qǐng)勿改動(dòng)主函數(shù)main()和其它
            函數(shù)中的任何內(nèi)容,僅在函數(shù)findStr()的花括號(hào)中填入你編寫(xiě)的若干語(yǔ)句。*/
            #include <stdio.h>
            #include <string.h>
            #include <conio.h>

            int findStr(char *str,char *substr)
            {

            }

            main()
            {
            char str[81], substr[3] ;
            int n ;

            clrscr() ;
            gets(str) ;
            gets(substr) ;
            puts(str) ;
            puts(substr) ;
            n=findStr(str, substr) ;
            printf("n=%d\n", n) ;
            ReadWrite() ;
            }

            ReadWrite()
            {
            char str[81], substr[3], ch;
            int n, len, i = 0;
            FILE *rf, *wf ;

            rf = fopen("in1.dat", "r") ;
            wf = fopen("out1.dat", "w") ;
            while(i < 5) {
            fgets(str, 80, rf) ;
            fgets(substr, 10, rf) ;
            len = strlen(substr) - 1 ;
            ch = substr[len] ;
            if(ch == '\n' || ch == 0x1a) substr[len] = 0 ;
            n=findStr(str, substr);
            fprintf(wf, "%d\n", n) ;
            i++ ;
            }
            fclose(rf) ;
            fclose(wf) ;
            }

            7./* 請(qǐng)編寫(xiě)函數(shù)Void countValue(int *a,int *n),它的功能是:
            求出1到1000之內(nèi)能被7或11整除但不能同時(shí)被7和11整除的所有整數(shù),
            并放在數(shù)組a中,然后通過(guò)n返回這些數(shù)的個(gè)數(shù)。
            注意:部分源程序存入在PROG1.C中。
            請(qǐng)改動(dòng)主函數(shù)main()和輸入輸出數(shù)據(jù)函數(shù)WriteDAT()的內(nèi)容。*/
            #include <stdio.h>
            int cnt, sum ;

            void countValue()
            {

            }

            void main()
            {
            cnt = sum = 0 ;

            countValue() ;
            printf("素?cái)?shù)的個(gè)數(shù)=%d\n", cnt) ;
            printf("滿足條件素?cái)?shù)值的和=%d", sum) ;
            writeDAT() ;
            }

            writeDAT()
            {
            FILE *fp ;

            fp = fopen("OUT6.DAT", "w") ;
            fprintf(fp, "%d\n%d\n", cnt, sum) ;
            fclose(fp) ;
            }

            8./* 請(qǐng)編寫(xiě)一個(gè)函數(shù)changestr(char *s),函數(shù)的功能是把s串中所有的字
            符前移一個(gè)位置,串中的第一個(gè)字符移到最后。
            例如:s串中原有的字符串為:Mn.123xyZ,則調(diào)用該函數(shù)后,s串中的
            內(nèi)容為:n.123xyZM。
            函數(shù)ReadWrite()實(shí)現(xiàn)從文件in3.dat中讀取兩個(gè)字符串,并調(diào)用函數(shù)
            changeStr(),最后把結(jié)果輸出到文件out3.dat中。
            注意:部分源程序存放在文件PROG1.C中。
            請(qǐng)勿改動(dòng)主函數(shù)main()和其它函數(shù)中的任何內(nèi)容,僅在函數(shù)
            changeStr()的花括號(hào)中填入你編寫(xiě)的若干語(yǔ)句。*/
            #include <stdio.h>
            int cnt, sum ;

            void countValue()
            {

            }

            void main()
            {
            cnt = sum = 0 ;

            countValue() ;
            printf("素?cái)?shù)的個(gè)數(shù)=%d\n", cnt) ;
            printf("滿足條件素?cái)?shù)值的和=%d", sum) ;
            writeDAT() ;
            }

            writeDAT()
            {
            FILE *fp ;

            fp = fopen("OUT6.DAT", "w") ;
            fprintf(fp, "%d\n%d\n", cnt, sum) ;
            fclose(fp) ;
            }


            9./* 請(qǐng)編制函數(shù)CalValue(),其功能要求是:1.求出這個(gè)文件中共有多
            少個(gè)正整數(shù)totNum;2.求這些數(shù)中的十位數(shù)位置上的數(shù)字2、4和8的數(shù)的
            個(gè)數(shù)totCnt;以及不滿足此條件的所有數(shù)的平均值totPjz,最后調(diào)用函
            數(shù)WriteDAT()把所求的結(jié)果輸出到文件out7.DAT中。
            注意:部分源程序存放在PROG1.C中。
            請(qǐng)勿改動(dòng)主函數(shù)main(),讀數(shù)據(jù)函數(shù)ReadDAT()和輸出數(shù)據(jù)函數(shù)
            WriteDAT()的內(nèi)容。*/
            #include <stdio.h>
            #include <conio.h>
            #define MAXNUM 200

            int xx[MAXNUM] ;
            int totNum = 0 ; /* 文件IN.DAT中共有多少個(gè)正整數(shù) */
            int totCnt = 0 ; /* 符合條件的正整數(shù)的個(gè)數(shù) */
            double totPjz = 0.0 ; /* 平均值 */

            int ReadDat(void) ;
            void WriteDat(void) ;

            void CalValue(void)
            {

            }

            void main()
            {
            clrscr() ;
            if(ReadDat()) {
            printf("數(shù)據(jù)文件IN.DAT不能打開(kāi)!\007\n") ;
            return ;
            }
            CalValue() ;
            printf("文件IN.DAT中共有正整數(shù)=%d個(gè)\n", totNum) ;
            printf("符合條件的正整數(shù)的個(gè)數(shù)=%d個(gè)\n", totCnt) ;
            printf("平均值=%.2lf\n", totPjz) ;
            WriteDat() ;
            }

            int ReadDat(void)
            {
            FILE *fp ;
            int i = 0 ;

            if((fp = fopen("in.dat", "r")) == NULL) return 1 ;
            while(!feof(fp)) {
            fscanf(fp, "%d,", &xx[i++]) ;
            }
            fclose(fp) ;
            return 0 ;
            }

            void WriteDat(void)
            {
            FILE *fp ;

            fp = fopen("OUT7.DAT", "w") ;
            fprintf(fp, "%d\n%d\n%.2lf\n", totNum, totCnt, totPjz) ;
            fclose(fp) ;
            }

            10./* 已知在文件IN.BAT中存有N個(gè)實(shí)數(shù)(N<200),函數(shù)ReadDAT()讀取
            這N個(gè)實(shí)數(shù)并存入數(shù)組XX中。
            請(qǐng)編制函數(shù)CalValue(),其功能要求是:1.求出這N個(gè)實(shí)數(shù)的平
            均值aver;2.分別求出這N個(gè)實(shí)數(shù)的整數(shù)部分值的平均值averint以
            及其小數(shù)部分值的平均值averdel,最后調(diào)用函數(shù)WriteDAT()把所求
            的結(jié)果輸出到文件out10.DAT中。
            注意:部分源程序存放在文件PROG1.C中。
            請(qǐng)勿改動(dòng)主函數(shù)main(),讀數(shù)據(jù)函數(shù)ReadDAT()和輸出數(shù)據(jù)函數(shù)
            WreitDAT的內(nèi)容。*/
            #include <stdio.h>
            #include <conio.h>
            #define MAXNUM 200

            float xx[MAXNUM] ;
            int N = 0 ; /* 文件IN.DAT中共有多少個(gè)實(shí)數(shù) */
            double aver = 0.0 ; /* 平均值 */
            double averint = 0.0 ; /* 整數(shù)部分值的平均值 */
            double averdec = 0.0 ; /* 小數(shù)部分值的平均值 */
            int ReadDat(void) ;
            void WriteDat(void) ;

            void CalValue(void)
            {

            }

            void main()
            {
            clrscr() ;
            if(ReadDat()) {
            printf("數(shù)據(jù)文件IN.DAT不能打開(kāi)!\007\n") ;
            return ;
            }
            CalValue() ;
            printf("文件IN.DAT中共有實(shí)數(shù)%d個(gè)\n", N) ;
            printf("平均值=%.2lf\n", aver) ;
            printf("整數(shù)部分值的平均值=%.2lf\n", averint) ;
            printf("小數(shù)部分值的平均值=%.2lf\n", averdec) ;
            WriteDat() ;
            }

            int ReadDat(void)
            {
            FILE *fp ;
            int j ;

            if((fp = fopen("in.dat", "r")) == NULL) return 1 ;
            while(!feof(fp)) {
            fscanf(fp, "%f,", &xx[N]) ;
            if(xx[N] > 0.001) N++ ;
            }
            fclose(fp) ;
            return 0 ;
            }

            void WriteDat(void)
            {
            FILE *fp ;

            fp = fopen("OUT10.DAT", "w") ;
            fprintf(fp, "%d\n%.2lf\n%.2lf\n%.2lf\n", N, aver, averint, averdec) ;
            fclose(fp) ;
            }    

            文章搜索
            1999年9月全國(guó)計(jì)算機(jī)等級(jí)考試四級(jí)機(jī)試試題及答案(已運(yùn)行通過(guò))網(wǎng)友評(píng)論網(wǎng)友評(píng)論
            版權(quán)聲明 --------------------------------------------------------------------------------------
                如果計(jì)算機(jī)等級(jí)考試網(wǎng)所轉(zhuǎn)載內(nèi)容不慎侵犯了您的權(quán)益,請(qǐng)與我們聯(lián)系,我們將會(huì)及時(shí)處理。如轉(zhuǎn)載本計(jì)算機(jī)等級(jí)考試網(wǎng)內(nèi)容,請(qǐng)注明出處。
             蕭雨