1 条题解

  • 0
    @ 2023-6-11 12:17:57

    C++ :

    #include<bits/stdc++.h>
    using namespace std;
    int main(){
    	map<string,string> m;
    	map<string,string>::iterator i;
    	string s1,s2;
    	bool t=0;
        while(1==1){
        	cin>>s1;
        	if(s1=="$"){
        		exit(0);
    		}else if(s1[0]=='#'){
    			s1.erase(s1.begin());
    			m[s1]=s1;
    			s2=s1;
    		}else if(s1[0]=='+'){
    			s1.erase(s1.begin());
    			m[s1]=s2;
    		}else if(s1[0]=='?'){
    			s1.erase(s1.begin());
    			for(i=m.begin();i!=m.end();i++){
    				if(i->second==s1){
    					cout<<i->first<<endl;
    					t=1;
    				}
    			}
    			if(t==0){
    				cout<<"no data"<<endl;
    			}
    		}
    	}
        return 0;
    }
    
    
    • 1

    信息

    ID
    2429
    时间
    1000ms
    内存
    128MiB
    难度
    (无)
    标签
    递交数
    0
    已通过
    0
    上传者