#include <iostream>
#include <fstream>
#include <deque>
#include <string>
struct Inv
{
std::string name;
int price;
int number;
};
using namespace std;
int main()
{
deque<Inv> dq_inv;
ifstream in("in.txt", ios::in);
if(!in)
return 1;
{
char buf[1000];
in.getline(buf, 1000, '\n');
in.getline(buf, 1000, '\n');
while(in)
{
Inv inv;
in >> inv.name;
in >> inv.price;
in >> inv.number;
if(!in.fail())
dq_inv.push_back(inv);
}
}
{
int counter = 0;
for(deque<Inv>::iterator it(dq_inv.begin()); it != dq_inv.end(); ++it)
{
Inv &inv = *it;
cout << "dq_inventory[" << counter << "]{";
cout << "m_itemName=\"" << inv.name << "\",";
cout << "m_itemPrice=" << inv.price << ",";
cout << "m_itemAmount=" << inv.number << "}" << endl;
++counter;
}
}
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8ZnN0cmVhbT4KI2luY2x1ZGUgPGRlcXVlPgojaW5jbHVkZSA8c3RyaW5nPgoKc3RydWN0IEludgp7CiAgICBzdGQ6OnN0cmluZyBuYW1lOwogICAgaW50IHByaWNlOwogICAgaW50IG51bWJlcjsKfTsKCnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgoKaW50IG1haW4oKQp7CiAgICBkZXF1ZTxJbnY+IGRxX2ludjsKCiAgICBpZnN0cmVhbSBpbigiaW4udHh0IiwgaW9zOjppbik7CgogICAgaWYoIWluKQogICAgICAgIHJldHVybiAxOwoKICAgIHsKICAgICAgICBjaGFyIGJ1ZlsxMDAwXTsKICAgICAgICBpbi5nZXRsaW5lKGJ1ZiwgMTAwMCwgJ1xuJyk7CiAgICAgICAgaW4uZ2V0bGluZShidWYsIDEwMDAsICdcbicpOwoKICAgICAgICB3aGlsZShpbikKICAgICAgICB7CiAgICAgICAgICAgIEludiBpbnY7CiAgICAgICAgICAgIGluID4+IGludi5uYW1lOwogICAgICAgICAgICBpbiA+PiBpbnYucHJpY2U7CiAgICAgICAgICAgIGluID4+IGludi5udW1iZXI7CiAgICAgICAgICAgIGlmKCFpbi5mYWlsKCkpCiAgICAgICAgICAgICAgICBkcV9pbnYucHVzaF9iYWNrKGludik7CiAgICAgICAgfQoKICAgIH0KCgogICAgewogICAgICAgIGludCBjb3VudGVyID0gMDsKICAgICAgICBmb3IoZGVxdWU8SW52Pjo6aXRlcmF0b3IgaXQoZHFfaW52LmJlZ2luKCkpOyBpdCAhPSBkcV9pbnYuZW5kKCk7ICsraXQpCiAgICAgICAgewogICAgICAgICAgICBJbnYgJmludiA9ICppdDsKICAgICAgICAgICAgY291dCA8PCAiZHFfaW52ZW50b3J5WyIgPDwgY291bnRlciA8PCAiXXsiOwogICAgICAgICAgICBjb3V0IDw8ICJtX2l0ZW1OYW1lPVwiIiA8PCBpbnYubmFtZSA8PCAiXCIsIjsKICAgICAgICAgICAgY291dCA8PCAibV9pdGVtUHJpY2U9IiA8PCBpbnYucHJpY2UgPDwgIiwiOwogICAgICAgICAgICBjb3V0IDw8ICJtX2l0ZW1BbW91bnQ9IiA8PCBpbnYubnVtYmVyIDw8ICJ9IiA8PCBlbmRsOwogICAgICAgICAgICArK2NvdW50ZXI7CiAgICAgICAgfQogICAgfQoKCiAgICByZXR1cm4gMDsKfQ==