南邮 OJ 1124 Hotel
来源:互联网 发布:少见的姓氏 知乎 编辑:程序博客网 时间:2024/06/04 18:55
Hotel
总提交 : 75 测试通过 : 15
比赛描述
Last year summer Max traveled to California for his vacation. He had a great time there: took many photos, visited famous universities, enjoyed beautiful beaches and tasted various delicious foods. It is such a good trip that Max plans to traveled there one more time this year. Maxis satisfied with the accommodation of the hotel he booked last year but he lost the card of that hotel and can not remember quite clearly what its name is. So Max searched in the web for the information of hotels in California and got piles of choices. Could you help Max pick out those that might be the right hotel?
输入
Input may consist of several test data sets. For each data set, it can be format as below:
For the first line, there is one string consisting of ‘*’, ‘?’ and ’a’-‘z’ characters. This string represents the hotel name that Max can remember. The ‘*’ and ’?’ is wildcard characters. ‘*’ matches zero or more lowercase character(s), and ‘?’ matches only one lowercase character.
In the next line there is one integer n (1<=n<=10000) representing the number of hotel Max found, and then n lines follow. Each line contains one string of lowercase character(s), the name of the hotel.
The length of every string doesn’t exceed 50.
输出
For each test data set, just simply output one integer in a line telling the number of hotel in the list whose name matches the one Max remembered.
样例输入
herbert
2
amazon
herbert
?ert*
2
amazon
hertert
*
2
amazon
anything
hertber?
2
amazon
herber
样例输出
1
1
2
0
题目来源
第九届中山大学程序设计竞赛预选题
#include<stdio.h>bool match(char *a, char *b){if('\0'==*a && '\0'==*b){return 1;}if('\0'==*a && *b!='\0' || '\0'!=*a && *b=='\0'){return 0;}if('?'==*a || *a==*b){return match(a+1, b+1);}if('*'==*a){a++;if(match(a, b)){return 1;}while(*b!='\0'){b++;if(match(a,b)){return 1;}}}return 0;}int main(){char a[51],b[51];int N,sum;while(scanf("%s",a)==1){scanf("%d",&N);sum = 0;while(N--){scanf("%s",b);if(match(a,b)){sum++;}}printf("%d\n",sum);}}
- 南邮 OJ 1124 Hotel
- uestc oj 1227 Hotel
- Hotel
- Hotel
- Hotel
- Hotel
- Hotel
- Hotel
- Hotel California
- Hotel California
- hotel california
- 3667 Hotel
- hku2585 hotel
- Hotel California
- POJ3667 Hotel
- 【模拟】Hotel
- POJ3667 hotel
- POJ3667--Hotel
- iterm的配置与学习
- vmware8破解版序列号+注册机下载
- android view startAnimation后setVisibility没有效果
- /etc/ethers
- 在Eclipse中搭建Python开发环境
- 南邮 OJ 1124 Hotel
- mysql优化建议
- 针对QTP连接oracle数据库问题总结
- 未能找到类型或命名空间名称“SYNCTMS”(是否缺少 using 指令或程序集引用?)
- struts 工作流程
- 递归 Seeding
- JavaScript的加载和运行
- 南邮 OJ 1125 Substring
- 用静态工厂方法代替构造器