#include #include #include #include using namespace std; int main (int argc, char * argv[]) { ifstream fin(argv[1], ios::binary); int len; string stock; string loadLen; string name[1002]; string type[1002]; string loadPrize; double prize[1002]; bool noOne = true; while (!fin.eof()) { getline(fin, loadLen, ' '); getline(fin, stock, '\n'); len = atoi(loadLen.c_str()); if (stock == "END") return ( 0 ); for (int z=0; z < len; z++) { getline(fin, name[z], ' '); getline(fin, type[z], ' '); getline(fin, loadPrize, '\n'); prize[z] = atof(loadPrize.c_str()); } cout << stock << endl; for (int i=0; i < len; i++) { noOne = true; cout << name[i] << ": "; if (type[i]=="buy") { for (int k = 0; k < len ; k++) { if (type[k] == "sell" && prize[k] <= prize[i]) { cout << name[k] << " "; noOne = false; } } } if (type[i]=="sell") { for (int k = 0; k < len ; k++) { if (type[k] == "buy" && prize[k] >= prize[i]) { cout << name[k] << " "; noOne = false; } } } if (noOne) cout << "NO-ONE"; cout << endl; } } }