题目1165:字符串匹配
#include <iostream>
#include
#include
#include
#include
#include
using namespace std; int main() { int n=0; while(cin>>n){ string *s=new string[n+1]; string *tmp=new string[n+1]; for(int i=0;i<=n;i++){ cin>>s[i]; tmp[i]=s[i].substr(0,s[i].length()); } for(int i=0;i<=n;i++){ for(int j=0;j<s[i].length();j++){ if(s[i][j]!='['&&s[i][j]!=']') s[i][j]=tolower(s[i][j]); } } int pos=0; int start=s[n].find('['); int end=s[n].find(']'); string head=s[n].substr(0,start); string tail=s[n].substr(end+1,s[n].length()-end); string *result=new string[end-start-1]; for(int i=start+1;i<end;i++){ result[pos]=head+s[n][i]+tail; for(int j=0;j<n;j++){ if(result[pos].compare(s[j])==0){ cout<<j+1<<" "<<tmp[j]<<endl; break; } } pos++; } } return 0; } /************************************************************** Problem: 1165 User: 爱理momoko Language: C++ Result: Accepted Time:0 ms Memory:1520 kb ****************************************************************/