大家逛超市是否为找东西而烦恼!!!???
#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万就够
本文发布于:2024-02-04 15:44:02,感谢您对本站的认可!
本文链接:https://www.4u4v.net/it/170710832856797.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
留言与评论(共有 0 条评论) |