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

  1. 
    
    <b id="glvx9"></b>
        1. <blockquote id="glvx9"><meter id="glvx9"></meter></blockquote>
            查看全部128種考試
            1
            2
            3
            4
            5
            6
            7
            8
            9
            10
            蕭雨  
            【字體: 二級C上機模擬試題及答案(4)
            二級C上機模擬試題及答案(4)
            djks.exam8.com 來源:考試吧(Exam8.com) 更新:2004-8-16 21:42:00 計算機等級考試 考試論壇
            函數(shù)ReadDat()實現(xiàn)從文件ENG.IN中讀取一篇英文文章存入到
            字符串?dāng)?shù)組xx中; 請編制函數(shù)ComWord()分別計算出10個不區(qū)分大
            小寫的英文單詞(you,for,your,on,no,if,the,in,to,all)的頻數(shù)
            并依次存入整型數(shù)組yy[0]至yy[9]中, 最后調(diào)用函數(shù)WriteDat( )
            把結(jié)果yy輸出到文件PS1.OUT中。
            原始數(shù)據(jù)文件存放的格式是:每行的寬度均小于80個字符, 含
            標(biāo)點符號和空格。
            注意: 部分源程序存放在PROG1.C中。文章每行中的單詞與單
            詞之間用空格或其它標(biāo)點符號分隔, 每單詞均小于20個字符。
            請勿改動主函數(shù)main()、讀數(shù)據(jù)函數(shù)ReadDat()和輸出數(shù)據(jù)函
            數(shù)WriteDat()的內(nèi)容。



            /*參考答案*/

            #include
            #include
            #include
            #include

            char WORD[10][10] = {"you", "for", "your", "on", "no","if","the","in","to","all"} ;
            char xx[50][80] ;
            int yy[10] ;
            int maxline = 0 ; /* 文章的總行數(shù) */

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

            void ComWord(void)
            {
            int i,j,k,n,len;
            char word[20],c;

            memset(yy,0,10*sizeof(int));

            for(i = 0; i < maxline; i++)
            {
            len = strlen(xx);

            n = 0;
            for(j = 0; j < len+1; j++)
            {
            c = xx[j];

            if((c>='a' && c<='z') || (c>='A' && c<='Z'))
            {
            word[n] = c;
            n++;
            }
            else
            {
            word[n] = '\0';
            for(k = 0; k < 10; k++)
            if(strcmpi(WORD[k],word) == 0)
            yy[k]++;
            n = 0;
            }
            }
            }
            }

            void main()
            {
            int i ;

            clrscr() ;
            for(i = 0 ; i < 10 ; i++) yy = 0 ;
            if(ReadDat()) {
            printf("數(shù)據(jù)文件ENG.IN不能打開!\n\007") ;
            return ;
            }
            ComWord() ;
            WriteDat() ;
            }

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

            if((fp = fopen("eng.in", "r")) == NULL) return 1 ;
            while(fgets(xx, 80, fp) != NULL) {
            p = strchr(xx, '\n') ;
            if(p) xx[p - xx] = 0 ;
            i++ ;
            }
            maxline = i ;
            fclose(fp) ;
            return 0 ;
            }

            void WriteDat(void)
            {
            FILE *fp ;
            int i ;

            fp = fopen("ps1.out", "w") ;
            for(i = 0 ; i < 10 ; i++) {
            printf("%s=%d\n", strupr(WORD), yy) ;
            fprintf(fp, "%d\n", yy) ;
            }
            fclose(fp) ;
            }
            轉(zhuǎn)帖于:計算機等級考試_考試吧
            文章搜索  
            看了本文的網(wǎng)友還看了:
            網(wǎng)友評論
            昵 稱: *  評 分: 1分 2分 3分 4分 5分
            標(biāo)題:   匿名發(fā)表    (共有條評論)查看全部評論>>
            版權(quán)聲明 -------------------------------------------------------------------------------------
              如果計算機等級考試網(wǎng)所轉(zhuǎn)載內(nèi)容不慎侵犯了您的權(quán)益,請與我們聯(lián)系,我們將會及時處理。如轉(zhuǎn)載本計算機等級考試網(wǎng)內(nèi)容,請注明出處。
            關(guān)于本站  網(wǎng)站聲明  廣告服務(wù)  聯(lián)系方式  付款方式  站內(nèi)導(dǎo)航  客服中心  友情鏈接  考試論壇  網(wǎng)站地圖
            Copyright © 2004-2008 考試吧計算機等級考試網(wǎng) All Rights Reserved    
            中國科學(xué)院研究生院權(quán)威支持(北京) 電 話:010-62168566 傳 真:010-62192699
            百度大聯(lián)盟黃金認(rèn)證  十佳網(wǎng)絡(luò)教育機構(gòu)  經(jīng)營許可證號:京ICP060677