201403-3 命令行选项
题目
思路
0分代码,路过的大佬求指正orz。
代码
#include
#include
#include
#include
#include
using namespace std;
int pra[30]={0};
void my_split(string cmd,vector &str){
int s=3;
while(s
int t=cmd.find(" ",s);
if(t==string::npos) t=cmd.size();
string temp=cmd.substr(s,t-s);
str.push_back(temp);
s=t+1;
}
}
map anylize(vector str){
map ans;
for(int i=0;i
string choice=str[i];
if(choice[0]!='-'||choice.size()!=2) return ans;
int t=choice[1]-'a';
switch(pra[t]){
case 0: return ans;
case 1: ans[choice]="NONE";break;
default : if(i+1
}
}
return ans;
}
int main(){
string pras;
cin>>pras;
for(int i=0;i
if(pras[i]==':') pra[pras[i-1]-'a']=2;
else pra[pras[i]-'a']=1;
}
int n;
cin>>n;
getchar();
for(int i=1;i<=n;i++){
string cmd;
getline(cin,cmd);
vector str;
my_split(cmd,str);
map ans=anylize(str);
cout<
//if(ans.size()==0) {cout<
for(map::iterator it=ans.begin();it!=ans.end();it++){
cout<first;
if(it->second!="NONE") cout<second;
}
cout<
}
return 0;
}
标签:201403,include,cout,int,cmd,str,ans,CCF,CSP
来源: https://blog.csdn.net/weixin_43944910/article/details/99763164