测试用例
4
xxx=lyf/${ttt}/test
ttt=www
yyy=seeyou
aa=/aaa/xxx/bbb/{xxx}/bbb/xxx/bbb/{yyy}/ccc
#include<iostream>
#include<string>
#include<vector>
using namespace std;
string fun(string s1,vector<string> v1){
string res="";
int ls=s1.size();
int l1=v1.size();
for(int i=0;i<=ls;i++){
if(s1[i]!='$'){
res+=s1[i];
}else{
string temp=s1.substr((i+2),3);
for(int j=0;j<l1;j++){
if(v1[j]==temp){
res+=v1[j+1];
i+=5;
}
}
}
}
return res;
}
int main()
{
int n;
string str;
vector<string> v;
while(cin>>n){
while(n){
cin>>str;
int len=str.size();
if(n>1){
v.push_back(str.substr(0,3));
v.push_back(str.substr(4,(len-4)));
}else{
string sf=str.substr(4,(len-4));
int len1=sf.size();
for(int k=0;k<len1;k++){
if(sf[k]=='$'){
sf=fun(sf.substr(0,(len1)),v);
len1=sf.size();
}
}
cout<<sf<<endl;
cout<<endl;
}
n--;
}
}
return 0;
}
交卷后的八分钟找到问题出在哪了,哎~~~~