0分求助
查看原帖
0分求助
952047
yellow_cloud楼主2024/9/30 19:29

请大佬赐教

#include<bits/stdc++.h>
using namespace std;
map<string,int>w;
int n,m;
int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		int x;
		cin>>x;
		if(x==1){
			string a;
			int b;
			cin>>a>>b;
			if(w[a]==0){
				m+=1;
			}
			w[a]=b;
			cout<<"OK"<<endl;
		}else if(n==2){
			string s;
			cin>>s;
			if(w[s]==0){
				cout<<"Not found"<<endl;
			}else{
				cout<<w[s]<<endl;
			}
		}else if(n==3){
			string s;
			cin>>s;
			if(w[s]==0){
				cout<<"Not found"<<endl;
			}else{
				w[s]=0;
				cout<<"Deleted successfully"<<endl;
				m-=1;
			}
		}else{
			cout<<m<<endl;
		}
	}
	
	return 0;
}
2024/9/30 19:29
加载中...