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

  1. 
    
    <b id="glvx9"></b>
        1. <blockquote id="glvx9"><meter id="glvx9"></meter></blockquote>
            網(wǎng)站首頁
            分類導(dǎo)航
            試題中心
            下載中心
            英語學(xué)習(xí)
            繽紛校園
            考試論壇
            網(wǎng)站留言
            客服中心
             2000年9月全國計算機(jī)等級考試四級機(jī)試試題
            【字體:
            2000年9月全國計算機(jī)等級考試四級機(jī)試試題
            http://www.sckbxx.com 來源:考試吧(Exam8.com) 點(diǎn)擊: 更新:2004-8-12

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

            void countValue()
            {

            }

            void main()
            {
            cnt = sum = 0 ;

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

            writeDAT()
            {
            FILE *fp ;

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


            2. /* 編寫函數(shù)sumValue( ),它的功能是:計算正整數(shù)n的所有因子(1和n除外)之
            和作為函數(shù)值返回。
            例如:n=20時,函數(shù)值為21。
            函數(shù)ReadWrite( )是實(shí)現(xiàn)從文件in9.dat中讀取兩個字符串,并調(diào)用函數(shù)
            sumValue(),最后把結(jié)果輸出到文件out9.dat中。
            注意:部分源程序存在文件PROG1.C中,請勿改動主函數(shù)main()和其它函數(shù)
            中的任何內(nèi)容,僅在函數(shù)sumValue()的花括號中填入你編寫的若干語句。 */
            #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./* 請編寫一個函數(shù)changeStr(char *s),函數(shù)的功能是把s串中所有的字
            母改寫成該字母的下一個字母,字母z改寫成字母a。大寫仍為大寫字母,
            小寫字母仍為小寫字母,其它的字符不變。
            函數(shù)ReadWrite()實(shí)現(xiàn)從文件in2.dat中讀取兩個字符串,并調(diào)用函
            數(shù)changestr(),最后把結(jié)果輸出到文件out2.dat中。
            注意:部分源程序存在文件PROG1.C中。請勿改動主函數(shù)main()和其
            它函數(shù)中的任何內(nèi)容,僅在函數(shù)changeStr()的花括號中填入你編寫的若干語名。*/
            #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的功能是:利用以下所示的簡單迭代方法求方程:
            cos(x)-x=0的一個實(shí)根。
            Xn+1=cos(Xn)
            迭代步驟如下:
            (1) 取x1初步值為0.0;
            (2) x0=x1,把x1,把x1的值賦給x0;
            (3) x1=cos(x0),求出一個新的x1;
            (4) 若x0-x1的絕對值小于0.000001,執(zhí)行步驟(5),否則執(zhí)行步驟(2);
            (5) 所求x1就是方程cos(x)-x=0的一個實(shí)根,作為函數(shù)值返回。
            請編寫函數(shù)countValue()實(shí)現(xiàn)程序的要求,最后調(diào)用函數(shù)writeDAT()把
            結(jié)果輸出到文件out4.dat中。
            注意:部分源程序存在文件PROG1.C中,請勿改動主函數(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中存有若干個(個數(shù)<200)四位數(shù)字的正整數(shù),
            函數(shù)ReadDAT()讀取這些正整數(shù)并存入數(shù)組xx中。
            請編制函數(shù)CalValue()其功能要求是:1.求出這個文件中共有多
            少個正整數(shù)totNum;2.求出這些數(shù)中的各位數(shù)字之和是奇數(shù)的數(shù)的個
            數(shù)totCnt,以及不滿足此條件的所有數(shù)的算術(shù)平均值totPjz,最后調(diào)
            用函數(shù)WriteDAT()把所求的結(jié)果輸出到文件OUT8.DAT中。
            注意:部分源程序存放在PROG1.C中。
            請勿改動主函數(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中共有多少個正整數(shù) */
            int totCnt = 0 ; /* 符合條件的正整數(shù)的個數(shù) */
            double totPjz = 0.0 ; /* 平均值 */

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

            void CalValue(void)
            {

            }

            void main()
            {
            clrscr() ;
            if(ReadDat()) {
            printf("數(shù)據(jù)文件IN.DAT不能打開!\007\n") ;
            return ;
            }
            CalValue() ;
            printf("文件IN.DAT中共有正整數(shù)=%d個\n", totNum) ;
            printf("符合條件的正整數(shù)的個數(shù)=%d個\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./* 編寫一個函數(shù)findstr(),該函數(shù)統(tǒng)計一個長度為2的子字符串在另一個
            字符串中出現(xiàn)的次數(shù)。例如,假定輸入的字符串為“asd asasdfg asd as
            zx67 asd mklo”,子字符串為“as”,則輸出6。
            函數(shù)ReadWrite()實(shí)現(xiàn)從文件in1.dat中讀取兩個字符串,并調(diào)用函數(shù)
            findStr(),最后把結(jié)果輸出到文件out1.dat中。
            注意:部分源程序存在文件PROG1.C中。請勿改動主函數(shù)main()和其它
            函數(shù)中的任何內(nèi)容,僅在函數(shù)findStr()的花括號中填入你編寫的若干語句。*/
            #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./* 請編寫函數(shù)Void countValue(int *a,int *n),它的功能是:
            求出1到1000之內(nèi)能被7或11整除但不能同時被7和11整除的所有整數(shù),
            并放在數(shù)組a中,然后通過n返回這些數(shù)的個數(shù)。
            注意:部分源程序存入在PROG1.C中。
            請改動主函數(shù)main()和輸入輸出數(shù)據(jù)函數(shù)WriteDAT()的內(nèi)容。*/
            #include <stdio.h>
            int cnt, sum ;

            void countValue()
            {

            }

            void main()
            {
            cnt = sum = 0 ;

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

            writeDAT()
            {
            FILE *fp ;

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

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

            void countValue()
            {

            }

            void main()
            {
            cnt = sum = 0 ;

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

            writeDAT()
            {
            FILE *fp ;

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


            9./* 請編制函數(shù)CalValue(),其功能要求是:1.求出這個文件中共有多
            少個正整數(shù)totNum;2.求這些數(shù)中的十位數(shù)位置上的數(shù)字2、4和8的數(shù)的
            個數(shù)totCnt;以及不滿足此條件的所有數(shù)的平均值totPjz,最后調(diào)用函
            數(shù)WriteDAT()把所求的結(jié)果輸出到文件out7.DAT中。
            注意:部分源程序存放在PROG1.C中。
            請勿改動主函數(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中共有多少個正整數(shù) */
            int totCnt = 0 ; /* 符合條件的正整數(shù)的個數(shù) */
            double totPjz = 0.0 ; /* 平均值 */

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

            void CalValue(void)
            {

            }

            void main()
            {
            clrscr() ;
            if(ReadDat()) {
            printf("數(shù)據(jù)文件IN.DAT不能打開!\007\n") ;
            return ;
            }
            CalValue() ;
            printf("文件IN.DAT中共有正整數(shù)=%d個\n", totNum) ;
            printf("符合條件的正整數(shù)的個數(shù)=%d個\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個實(shí)數(shù)(N<200),函數(shù)ReadDAT()讀取
            這N個實(shí)數(shù)并存入數(shù)組XX中。
            請編制函數(shù)CalValue(),其功能要求是:1.求出這N個實(shí)數(shù)的平
            均值aver;2.分別求出這N個實(shí)數(shù)的整數(shù)部分值的平均值averint以
            及其小數(shù)部分值的平均值averdel,最后調(diào)用函數(shù)WriteDAT()把所求
            的結(jié)果輸出到文件out10.DAT中。
            注意:部分源程序存放在文件PROG1.C中。
            請勿改動主函數(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中共有多少個實(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不能打開!\007\n") ;
            return ;
            }
            CalValue() ;
            printf("文件IN.DAT中共有實(shí)數(shù)%d個\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) ;
            }                  


            文章錄入:蕭雨    責(zé)任編輯:Exam8.com  
             版權(quán)聲明
               如果本網(wǎng)站所轉(zhuǎn)載內(nèi)容不慎侵犯了您的權(quán)益,請與我們聯(lián)系,我們將會及時處理。如轉(zhuǎn)載本網(wǎng)內(nèi)容,請注明出處。
             發(fā)表評論
            關(guān)于本站 網(wǎng)站聲明 廣告服務(wù)  聯(lián)系方式  付款方式  站內(nèi)導(dǎo)航  客服中心  友情鏈接   
            Copyright © 2004-2006 考試吧 (Exam8.com) All Rights Reserved 
            中國科學(xué)院研究生院中關(guān)村園區(qū)(北京市海淀區(qū))