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

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

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

        2010計(jì)算機(jī)等級考試三級數(shù)據(jù)庫技術(shù)上機(jī)模擬題(3)

        字號:

        2010計(jì)算機(jī)等級考試三級數(shù)據(jù)庫技術(shù)上機(jī)模擬題(3)

            已知在文件IN.DAT中存有100個(gè)產(chǎn)品銷售記錄,每個(gè)產(chǎn)品銷售記錄由產(chǎn)品代碼dm(字符型4位)、產(chǎn)品名稱mc(字符型10位)、單價(jià)dj(整型)、數(shù)量sl(整型)、金額je(長整型)幾部分組成。其中:金額=單價(jià)*數(shù)量可計(jì)算得出。函數(shù)ReadDat()的功能是讀取這100個(gè)銷售記錄并存入結(jié)構(gòu)數(shù)組sell中。請編制函數(shù)SortDat(),其功能要求:按產(chǎn)品代碼從大到小進(jìn)行排列,若產(chǎn)品代碼相同,則按金額從大到小進(jìn)行排列,最終排列結(jié)果仍存入結(jié)構(gòu)數(shù)組sell中,最后調(diào)用函數(shù)WriteDat()把結(jié)果輸出到文件OUT10.DAT中。
            注意:部分源程序已給出。
            請勿改動(dòng)主函數(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; /*單價(jià)*/
            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()
            {
            FILE *fp;
            int i;
            fp=fopen("OUT10.DAT","w");
            for(i=0;i<100;i++){
            fprintf(fp,"%s %s M ] 1d\n",sell[i].dm,sell[i].mc,sell[i].dj,sell[i].sl,sell[i].je);
            }
            fclose(fp);
            }
            --------------------------------------------------------------------------------
            void SortDat( )
            {int I,j;
            PRO xy;
            for(I=0;I<99;I++)
            for(j=I+1;j<100;j++)
            if(sell[I].dm
            {xy=sell[I];
            sell[I]=sell[j];
            sell[j]=xy;}
            else if(sell[I].dm==sell[j].dm)
            if(sell[I].je
            {xy=sell[I];
            sell[I]=sell[j];
            sell[j]=xy;}
            }