日本一本亚洲最大|日本午夜免费啪视频在|国产自产在线视频一区|亚洲福利精品视频

    <object id="4ihfc"></object>
      
      
    1. <object id="4ihfc"></object>
    2. 我要投稿 投訴建議

      計算機(jī)等級考試三級網(wǎng)絡(luò)技術(shù)試題

      時間:2022-08-05 05:10:32 計算機(jī)等級 我要投稿
      • 相關(guān)推薦

      2013年計算機(jī)等級考試三級網(wǎng)絡(luò)技術(shù)試題

        已知文件IN.DAT中存有100個產(chǎn)品銷售記錄,每個產(chǎn)品銷售記錄由產(chǎn)品代碼dm(字符型4位)、產(chǎn)品名稱mc(字符型10位)、單價dj(整型)、數(shù)量sl(整型)、金額je(長整型)幾部分組成。其中:金額=單價×數(shù)量。函數(shù)ReadDat()的功能是讀取這100個銷售記錄并存入結(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é)果輸出到文件OUT.DAT中。

      2013年計算機(jī)等級考試三級網(wǎng)絡(luò)技術(shù)試題

        注意:部分源程序已給出。請勿改動主函數(shù)main()、讀函數(shù)ReadDat()和寫函數(shù)WriteDat()的內(nèi)容。

        【試題程序】

        #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()

        {

        FILE *fp;

        int i;

        fp = fopen("OUT.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);

        }

      http://krishna123.com/