一道汇总题目,貌似是一ERP公司的面试题?

//struct Material{  Quota{ struct Bill{是题目给出的结构体。
/*材料*/
struct Material{
    string code;
    string name;
    string spec;
    string vendor;
    string unit;
    double quantity;
    double cost; //这个是材料单价。。。取名这样。。。坑
    double cost_sum;
};

/*定额*/
struct Quota{
    string code;
    string name;
    string content;
    string unit;
    double quantity;
    double cost;
    double cost_sum;
    std::list<Material* > materials;
};


/*清单*/
struct Bill{
    string code;
    string name;
    string spec;
    string content;
    string unit;
    double quantity;
    double cost;
    double cost_sum;
    std::list<Quota* > quotas;
};




实现一种统计方法,汇总制定清单项目,std::list<Bill*>中各种材料的使用量,以及该材料被哪些额定所使用,并记录使用量

注:a.材料汇总时,编码.名称,规格型号,厂商,几辆单位,单价均相同时才被视为同一材料。

b.代码中加入有效注释


我只找了一个Bill,只是一个测试,没优化过,速度慢。

#include "stdafx.h"
#include <vector>
#include <string>
#include <iostream>
#include <list>
#include <time.h>
using namespace std;

int serial = 0;
// struct Material{  Quota{ struct Bill{是题目给出的结构体。
/*材料*/
struct Material{
    string code;
    string name;
    string spec;
    string vendor;
    string unit;
    double quantity;
    double cost;
    double cost_sum;
};

/*定额*/
struct Quota{
    string code;
    string name;
    string content;
    string unit;
    double quantity;
    double cost;
    double cost_sum;
    std::list<Material* > materials;
};


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值