亚洲免费乱码视频,日韩 欧美 国产 动漫 一区,97在线观看免费视频播国产,中文字幕亚洲图片

      1. <legend id="ppnor"></legend>

      2. 
        
        <sup id="ppnor"><input id="ppnor"></input></sup>
        <s id="ppnor"></s>

        2006年9月全國(guó)等級(jí)考試三級(jí)c語(yǔ)言上機(jī)題庫(kù)(四十三)

        字號(hào):

        ☆題目43(無(wú)憂id 82 字符排序題)
            無(wú)憂id 82題(只是將結(jié)果按“從大到小”排序)
            函數(shù)ReadDat()實(shí)現(xiàn)從文件in.dat中讀取20行數(shù)據(jù)存放到字符串?dāng)?shù)組xx中(每行字符串長(zhǎng)度均小于80)。請(qǐng)編制函數(shù)jsSort(),其函數(shù)的功能是:以行為單位對(duì)字符串變量的下標(biāo)為奇數(shù)的字符按其ASCII值從小到大的順序進(jìn)行排序,排序后的結(jié)果仍按行重新存入字符串?dāng)?shù)組xx中,最后調(diào)用函數(shù)WriteDat()把結(jié)果xx輸出到文件out.dat中。
            例如:位置   0 1 2 3 4 5 6 7 
            源字符串 a b c d e f g h
            則處理后字符串 a h c f e d g b
            部分源程序存在文件prog1.c中。
            請(qǐng)勿改動(dòng)主函數(shù)main()、讀數(shù)據(jù)函數(shù)ReadDat()和輸出數(shù)據(jù)函數(shù)WriteDat()的內(nèi)容。
            #include
            #include
            #include
            char xx[20][80];
            void jsSort()
            {int i,j,k,strl;
            char ch;
            for(i=0;i<20;i++)
            { strl=strlen(xx[i]);
            for(j=1;j    for(k=j+2;k    if(xx[i][j]>xx[i][k]) { ch=xx[i][j];xx[i][j]=xx[i][k];xx[i][k]=ch;}
            }
            }
            void main()
            {
            readDat();
            jsSort();
            writeDat();
            }
            readDat()
            {
            FILE *in;
            int i=0;
            char *p;
            in=fopen("in.dat","r");
            while(i<20&&fgets(xx[i],80,in)!=NULL){
            p=strchr(xx[i],'\n');
            if(p)*p=0;
            i++;
            }
            fclose(in);
            }
            writeDat()
            {
            FILE *out;
            int i;
            out=fopen("out.dat","w");
            clrscr();
            for(i=0;i<20;i++){
            printf("%s\n",xx[i]);
            fprintf(out,"%s\n",xx[i]);
            }
            fclose(out);
            }