#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <stack>
#include <sstream>
using namespace std;
//1165
const int maxn=1e3+10;
string a[maxn],A[maxn];
string cmp;
int main(){
int n;
// freopen("input.txt","r",stdin);
while(cin>>n){
for(int i=0;i<n;i++){
cin>>a[i];
A[i]=a[i];
for(int j=0;j<A[i].size();j++)
A[i][j]=toupper(A[i][j]);
}
cin>>cmp;
for(int i=0;i<cmp.size();i++) cmp[i]=toupper(cmp[i]);
int p1=cmp.find('[');
if(p1==string::npos){ //无方括号
for(int i=0;i<n;i++)
if(A[i]==cmp)
cout<<i+1<<" "<<a[i]<<endl;
}
else{
int p2=cmp.find(']');
string pre=cmp.substr(0,p1);
string mid=cmp.substr(p1+1,p2-p1-1);
string post=cmp.substr(p2+1);
for(int i=0;i<n;i++){
if(pre==A[i].substr(0,p1) && post==A[i].substr(p1+1) && mid.find(A[i][p1]!=string::npos) )
cout<<i+1<<" "<<a[i]<<endl;
}
}
}
return 0;
}
/**************************************************************
Problem: 1165
User: cust123
Language: C++
Result: Accepted
Time:0 ms
Memory:1540 kb
****************************************************************/
题目1165:字符串匹配
最新推荐文章于 2020-11-26 10:22:06 发布