1345. 序号命名【难度: 简单 / 模拟 字符串】
作者:互联网
https://www.acwing.com/problem/content/1347/
#include<bits/stdc++.h>
using namespace std;
string s,ss,a;
vector<string>ve;
string hush[10]={"","","ABC","DEF","GHI","JKL","MNO","PRS","TUV","WXY"};
int main(void)
{
cin>>s;
while(cin>>a)
{
bool flag=1;
if(a.size()!=s.size()) continue;
for(int i=0;i<a.size();i++)
if(hush[s[i]-'0'].find(a[i])==-1) {flag=0;break;}
if(flag) ve.push_back(a);
}
sort(ve.begin(),ve.end());
for(int i=0;i<ve.size();i++) cout<<ve[i]<<endl;
if(!ve.size()) puts("NONE");
return 0;
}
标签:ve,int,1345,cin,字符串,flag,序号,string,size 来源: https://blog.csdn.net/qq_46527915/article/details/121127976