为啥只能操作三次
查看原帖
为啥只能操作三次
575655
Chtholly_is_cute楼主2024/2/25 11:37
#include<bits/stdc++.h>
using namespace std;
map<string,int>mp;
int main(){
    int k;
    cin>>k;
    string s;
    int scr,ope;
    for(int i=1;i<=k;++i){
        cin>>ope;
        if(ope==1){
            cin>>s>>scr;
            mp[s]=scr;
            cout<<"OK\n";
        }
        else if(ope==2){
            cin>>s;
            if(mp.count(s)==0){
                cout<<"Not found\n";
            }
            else cout<<mp[s]<<endl;
        }
        else if(ope==3){
            if(mp.count(s)==0){
                cout<<"Not found\n";
            }
            else{
                cout<<"Deleted successfully\n";
                mp.erase(mp.find(s));
            }
        }
        else if(ope==4){
            cout<<mp.size()<<endl;
        }
    }
}
2024/2/25 11:37
加载中...