大家逛超市是否为找东西而烦恼!!!???
#include<bits/stdc++.h>
#include<windows.h>
using namespace std;
map <string, pair <int, int> > m;
const int N = 1e6 + 10;
string f[N];
int len;
bool fx[N], fy[N];
int main(){
while(1) {
int a;
cout << "1.查找" << endl << "2.存入" << endl << "3.所有物品" << endl;
cin >> a;
system ("cls");
if (a == 1) {
string st;
cout << "请输入查找对象" << endl;
cin >> st;
pair <int, int> z = m[st];
int xx = z.first;
int yy = z.second;
if (xx == 0 || yy == 0) cout << "不存在" << endl;
else cout << xx << ' ' << yy << endl;
system ("pause");
system ("cls");
}
else if (a == 2) {
string st;
cout << "请输入存入对象的名称,以及它的坐标(x > 0, y > 0)" << endl;
int x, y;
cin >> st;
cin >> x >> y;
if (fx[x] && fy[y]) cout << "该位置已存在物品" << endl;
else {
m[st] = make_pair (x, y);
f[++len] = st;
fx[x] = true;
fy[y] = true;
cout << "已存入" << endl;
}
system ("pause");
system ("cls");
}
else if (a == 3) {
cout << "共" << len << "件物品:" << endl;
for (int i = 1; i <= len; i++)
cout << f[i] << ' ' << m[f[i]].first << ' ' << m[f[i]].second << endl;
system ("pause");
system ("cls");
}
}
return 0;
}
如果你是超市经理,请别忘了给我钱,我不贪,1万就够