社区讨论
全WA为啥
P5266【深基17.例6】学籍管理参与者 2已保存回复 1
讨论操作
快速查看讨论及其快照的属性,并进行相关操作。
- 当前回复
- 1 条
- 当前快照
- 1 份
- 快照标识符
- @lo2yfrop
- 此快照首次捕获于
- 2023/10/23 21:49 2 年前
- 此快照最后确认于
- 2023/10/23 21:49 2 年前
样例过了但是全红
CPP#include <iostream>
#include <map>
#include <string.h>
using namespace std;
map<string,int> mp;
int type,n;
string s;
int main()
{
cin>>n;
for(int i=0;i<n;i++)
{
cin>>type;
if(type==0)return 0;
else if(type==1)
{
cin>>s;
int x;
cin>>x;
mp[s]=x;
cout<<"OK\n";
}
else if(type==2){
cin>>s;
if(!mp.count(s)){
cout<<"Not found\n";
}else{
cout<<mp[s]<<endl;
}
}else if(type==3){
cin>>s;
if(mp.count(s)){
mp.erase(s);
cout<<"Deleted successfully"<<endl;
}
else{
cout<<"Not found\n"<<endl;
}
}else if(type==4)cout<<mp.size()<<endl;
}
}
回复
共 1 条回复,欢迎继续交流。
正在加载回复...