标题:请问 PRO XY 意思
取消只看楼主
wymyhome
Rank: 1
等 级:新手上路
帖 子:29
专家分:4
注 册:2009-7-8
结帖率:84.21%
已结贴  问题点数:20 回复次数:0 
请问 PRO XY 意思
小弟刚入门不久 请问 里面的     PRO  xy; 是个什么意思啊?我还没有看到过·· #include <stdio.h>
#include <string.h>
#include <conio.h>
#include <stdlib.h>
#define  MAX 100
typedef  struct
{
    char  dm[5];        /* 产品代码 */
    char  mc[11];        /* 产品名称 */
    int  dj;            /* 单价 */
    int  sl;            /* 数量 */
    long  je;            /* 金额 */
} PRO;
PRO  sell[MAX];
void ReadDat();
void WriteDat();
void SortDat()
{
    int  i, j;
    PRO  xy;
    for (i=0; i<99; i++)
        for (j=i+1; j<100; j++)
            if (strcmp(sell[i].dm, sell[j].dm) < 0)
            {
                xy = sell[i];
                sell[i] = sell[j];
                sell[j] = xy;
            }
            else if (strcmp(sell[i].dm, sell[j].dm) == 0)
            {
                if (sell[i].je < sell[j].je)
                {
                    xy = sell[i];
                    sell[i] = sell[j];
                    sell[j] = xy;
                }
            }
}
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("OUT.DAT", "w");
    for (i=0; i<100; i++)
    {
        printf("%s %s %4d %5d %5d\n",
            sell[i].dm, sell[i].mc, sell[i].dj, sell[i].sl, sell[i].je);
        fprintf(fp, "%s %s %4d %5d %5d\n",
            sell[i].dm, sell[i].mc, sell[i].dj, sell[i].sl, sell[i].je);
    }
    fclose(fp);
}
搜索更多相关主题的帖子: PRO 
2009-09-19 17:31



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-286214-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.128526 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved