- P122's solution
P122's Solution
- 2025-9-5 18:35:13 @
出题人题解。
#include<bits/stdc++.h>
using namespace std;
int nm,temp;
string str;
char chr;
map<char,int>mp;
int main(){
ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
cin>>nm;
for(int i=1;i<=nm;++i){
cin>>str;
if(str=="define"){
cin>>chr>>temp;
mp[chr]=temp;
}
if(str=="plus"){
cin>>chr>>temp;
mp[chr]+=temp;
}
if(str=="minus"){
cin>>chr>>temp;
mp[chr]-=temp;
}
if(str=="times"){
cin>>chr>>temp;
mp[chr]*=temp;
}
if(str=="divide"){
cin>>chr>>temp;
mp[chr]/=temp;
}
if(str=="out"){
cin>>chr;
cout<<mp[chr]<<endl;
}
}
return 0;
}