久久久国产精品秘人口麻豆|永久免费AV无语国产|人成电影免费中文字幕|久久AV嫩草影院2

    1. <dfn id="yitbn"><samp id="yitbn"><progress id="yitbn"></progress></samp></dfn>

          <div id="yitbn"></div>

          1. 網(wǎng)站首頁
            分類導航
            試題中心
            下載中心
            英語學習
            繽紛校園
            考試論壇
            網(wǎng)站留言
            客服中心
             2003年4月全國計算機等級考試三級網(wǎng)絡技術上機考試題
            【字體:
            2003年4月全國計算機等級考試三級網(wǎng)絡技術上機考試題
            http://www.eeeigo.com 來源:考試吧(eeeigo.com) 點擊: 更新:2004-8-11

                1.已知在文件IN.DAT中存有100個產(chǎn)品銷售記錄,每個產(chǎn)品銷售記錄由產(chǎn)品代碼dm(字符型4位),產(chǎn)品名稱mc(字符型10位),單價dj(整型),數(shù)量sl(整型),金額je(長整型)四部分組成。其中:金額=單價*數(shù)量計算得出。函數(shù)ReadDat()是讀取這100個銷售記錄并存入結構數(shù)組sell中。請編制函數(shù)SortDat(),其功能要求:按產(chǎn)品代碼從大到小進行排列,若產(chǎn)品代碼相同,則按金額從大到小進行排列,最終排列結果仍存入結構數(shù)組sell中,最后調(diào)用函數(shù)WriteDat()把結果輸出到文件OUT10.DAT中。

            部分源程序已給出。

            請勿改動主函數(shù)main()、讀數(shù)據(jù)函數(shù)ReadDat()和輸出數(shù)據(jù)函數(shù)WriteDat()的內(nèi)容。

            #include

            #include

            #include

            #include

            #include


            #define MAX 100

            typedef struct{

            char dm[5]; /*產(chǎn)品代碼*/

            char mc[11]; /*產(chǎn)品名稱*/

            int dj; /*單價*/

            int sl; /*數(shù)量*/

            long je; /*金額*/

            }PRO;

            PRO sell[MAX];

            void ReadDat();

            void WriteDat();


            void SortDat()

            {


            }


            void main()

            {

            memset(sell,0,sizeof(sell));

            ReadDat();

            SortDat();

            WriteDat();

            }


            void ReadDat()

            {

            FILE *fp;

            char str[80],ch[11];

            int i;


            fp=fopen("IN.DAT","r");

            for(i=0;i<100;i++){

            fgets(str,80,fp);

            memcpy(sell[i].dm,str,4);

            memcpy(sell[i].mc,str+4,10);

            memcpy(ch,str+14,4);ch[4]=0;

            sell[i].dj=atoi(ch);

            memcpy(ch,str+18,5);ch[5]=0;

            sell[i].sl=atoi(ch);

            sell[i].je=(long)sell[i].dj*sell[i].sl;

            }

            fclose(fp);

            }


            void WriteDat(void)

            {

            FILE *fp;

            int i;


            fp=fopen("OUT10.DAT","w");

            for(i=0;i<100;i++){

            fprintf(fp,"%s %s %4d %5d %10Ld\n", sell[i].dm,sell[i].mc,sell[i].dj,sell[i].sl,sell[i].je);

            }

            fclose(fp);

            }"


            --------------------------------------------------------------------------------


            注:這時也是采用冒泡法進行排序。與前面的冒泡法在寫法上有所不同請注意區(qū)分。

            void SortDat()

            {

            int i,j;

            PRO swap;

            for(i=0;i for(j=0;j { if(strcmp(sell[j].dm,sell[j+1].dm)<0) /*用函數(shù)strcmp判斷兩個字符串的大小*/

            { swap=sell[j]; sell[j]=sell[j+1]; sell[j+1]=swap; }

            if(strcmp(sell[j].dm,sell[j+1].dm)==0&&sell[j].je {

            swap=sell[j];

            sell[j]=sell[j+1];

            sell[j+1]=swap;

            }

            }

            }

            若產(chǎn)品代碼相同,則按金額從大到小進行排列沒有體現(xiàn)!


            2.six+six+six=nine+nine的個數(shù)cnt及它們的和sum,s,i,n,e是0-9自然數(shù),但s,n不能為0.

            如 984+984+984=1476+1476,

            我臨時編的(可能算法不太好)


            main()

            {

            int i,j,cnt=0;

            float sum=0;

            for(i=100;i<1000;i++)

            for(j=1000;j<10000;j++)

            {

            if(i+i+i==j+j)

            {

            cnt++;

            sum=sum+i+j;

            printf("%d+%d+%d=%d+%d\n",i,i,i,j,j);

            }

            }

            printf("%d,%f",cnt,sum);

            }


            參考這個:for(i=666;i<1000;i++)

            if((i/10%10=(3*i/2)/100%10)&&((i*3/2)/1000=(i*3/2)/10%10)

            {cnt++;

            sum+=(5/2)*i;

            }

            3.函數(shù)ReadDat()實現(xiàn)從文件ENG.IN中讀取一篇英文文章,存入到字符串數(shù)組xx中;請編制函數(shù)encryptChar(),按給定的替代關系對數(shù)組xx中的所有字符進行替代,仍存入數(shù)組xx的對應的位置上,最后調(diào)用函數(shù)WriteDat()把結果xx輸出到文件PS4.DAT中。


            替代關系:f(p)=p*11 mod 256 (p是數(shù)組中某一個字符的ASCII值,f(p)是計算后新字符的ASCII值),如果計算后f(p)值小于等于32或f(p)對應的字符是大寫字母,則該字符不變,否則將f(p)所對應的字符進行替代。


            部分源程序已給出。原始數(shù)據(jù)文件存放的格式是:每行的寬度均小于80個字符。


            請勿改動主函數(shù)main()、讀數(shù)據(jù)函數(shù)ReadDat()和輸出數(shù)據(jù)函數(shù)WriteDat()的內(nèi)容。


            #include


            #include


            #include


            #include

            unsigned char xx[50][80];


            int maxline=0;/*文章的總行數(shù)*/

            int ReadDat(void)


            void WriteDat(void)

            void encryptChar()


            {

            }

            void main()


            {


            clrscr();


            if(ReadDat()){


            printf(\"數(shù)據(jù)文件ENG.IN不能打開!\\n\\007\");


            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(xx[i],80,fp)!=NULL){


            p=strchr(xx[i],'\\n');


            if(p)*p=0;


            i++;


            }


            maxline=i;


            fclose(fp);


            return 0;


            }

            void WriteDat(void)


            {


            FILE *fp;


            int i;

            fp=fopen(\"ps4.dat\",\"w\");


            for(i=0;i printf(\"%s\\n\",xx[i]);


            fprintf(fp,\"%s\\n\",xx[i]);


            }


            fclose(fp);


            }

            --------------------------------------------------------------------------------

            注:下題1相似,只是它要求對f(p)進行判斷。


            void encryptchar()


            {


            int i;


            char *pf;


            for(i=0;i {pf=xx[i];


            while(*pf!=0)


            {if(*pf*11%256>='A'&&*pf*11%256<='Z'||*pf*11%256<32)


            {pf++;continue;}


            *pf=*pf*11%256;


            pf++;


            }


            }


            }


            void encryptChar()


            {


            int i,j,t;


            for(i=0;i {


            for(j=0;j {


            t=xx[i][j]*11%256;


            if(t<=32 || t>='A' && t<='Z') continue;


            xx[i][j]=t;


            }


            }


            }


            4.南開第一題

            函數(shù)ReadDat()實現(xiàn)從文件ENG.IN中讀取一篇英文文章,存入到字符串數(shù)組xx中;請編制函數(shù)encryptChar(),按給定的替代關系對數(shù)組xx中的所有字符進行替代,仍存入數(shù)組xx的對應的位置上,最后調(diào)用函數(shù)WriteDat()把結果xx輸出到文件PS10.DAT中。

            替代關系:f(p)=p*11 mod 256 (p是數(shù)組中某一個字符的ASCII值,f(p)是計算后新字符的ASCII值),如果原字符的ASCII值是偶數(shù)或計算后f(p)值小于等于32,則該字符不變,否則將f(p)所對應的字符進行替代。

            部分源程序已給出,原始數(shù)據(jù)文件存放的格式是:每行的寬度均小于80個字符。

            請勿改動主函數(shù)main()、讀數(shù)據(jù)函數(shù)ReadDat()和輸出數(shù)據(jù)函數(shù)WriteDat()的內(nèi)容。

            #include

            #include

            #include

            #include


            unsigned char xx[50][80];

            int maxline=0;/*文章的總行數(shù)*/


            int ReadDat(void)

            void WriteDat(void)


            void encryptChar()

            {


            }


            void main()

            {

            clrscr();

            if(ReadDat()){

            printf("數(shù)據(jù)文件ENG.IN不能打開!\n\007");

            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(xx[i],80,fp)!=NULL){

            p=strchr(xx[i],'\n');

            if(p)*p=0;

            i++;

            }

            maxline=i;

            fclose(fp);

            return 0;

            }


            void WriteDat(void)

            {

            FILE *fp;

            int i;

            fp=fopen("ps10.dat","w");

            for(i=0;i printf("%s\n",xx[i]);

            fprintf(fp,"%s\n",xx[i]);

            }

            fclose(fp);

            }


            --------------------------------------------------------------------------------


            注:在ReadDat()函數(shù)中由于fgets()函數(shù)讀入數(shù)據(jù)時沒有讀入字符串結束符'\0',因

            而用while()循環(huán)在xx數(shù)組每一行未尾將換行符'\n'替換成結束符'\0'。

            編寫的函數(shù)如下:該函數(shù)的基本算法是——讓字符指針pf指向每一行的開頭然后逐一往

            后移動,在移動過程中按要求進行轉換。*pf%2==0用于判斷是否為偶數(shù)。if()條件語

            句用于控制不替代字符。


            解法1:


            void encryptChar()

            {

            int i;

            char *pf;

            for(i=0;i {pf=xx[i]; /*每行字符個數(shù)*/

            while(*pf!=0)

            {if(*pf%2==0||*pf*11%256<32)

            {pf++;continue;}

            *pf=*pf*11%256;

            pf++;

            }

            }


            }


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