原题:http://codeforces.com/gym/100307/problem/F
Problem F
思路:
题目又臭又长,直接看样例就知道要干什么了。逐一检查就行
源代码:
#include <iostream> #include <string> #include <cstdlib> #include <cstring> using namespace std; string stand,tmp; string ans[1001]; int n=0,p=0; bool judge() { char ch1,ch2; int len=tmp.size()-1; if (len!=8) return false; for (int i=0;i<=len;i++) { ch1=stand[i],ch2=tmp[i]; if ((ch2<'0' || ch2>'9') && (ch2<'A' || ch2>'Z')) return false; if (ch1=='*') continue; if (ch1!=ch2) return false; } return true; } int main() { freopen("fraud.in","r",stdin); freopen("fraud.out","w",stdout); cin>>stand; cin>>n; for (int i=1;i<=n;i++) { cin>>tmp; if (judge()) { p++; ans[p]=tmp; } } cout<<p<<endl; if (!p) exit(0); for (int i=1;i<=p;i++) cout<<ans[i]<<endl; fclose(stdin); fclose(stdout); return 0; }