九度机试 题目1165:字符串匹配 2008年北京航空航天大学计算机研究生机试真题
来源:互联网 发布:淘宝黑号是永久的吗 编辑:程序博客网 时间:2024/05/17 03:56
#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****************************************************************/
0 0
- 九度机试 题目1165:字符串匹配 2008年北京航空航天大学计算机研究生机试真题
- 题目1163:素数 2008年北京航空航天大学计算机研究生机试真题
- 题目1163:素数(2008年北京航空航天大学计算机研究生机试真题)
- 2008--2009年北京航空航天大学计算机研究生机试真题
- 简单的素数问题(2008年北京航空航天大学计算机研究生机试真题)
- 2008年清华大学计算机研究生机试真题
- 2008年清华大学计算机研究生机试真题
- 2006年清华大学计算机研究生机试真题
- 2010年清华大学计算机研究生机试真题
- 2000年清华大学计算机研究生机试真题
- 2012年清华大学计算机研究生机试真题
- 2000年清华大学计算机研究生机试真题
- 2006年清华大学计算机研究生机试真题
- 2009年清华大学计算机研究生机试真题
- 2010年清华大学计算机研究生机试真题
- 2011年清华大学计算机研究生机试真题
- 题目1080:进制转换(2008年清华大学计算机研究生机试真题)ps:用java太简单了
- 题目1065:输出梯形(2001年清华大学计算机研究生机试真题(第II套))
- 需求用例分析之一:异常流
- 黑马程序员-Oracle(第六讲)sql1992
- C和指针课后习题(第六章)
- [LeetCode] Spiral Matrix
- 工厂模式和策略模式的区别
- 九度机试 题目1165:字符串匹配 2008年北京航空航天大学计算机研究生机试真题
- 电子类电路图
- HDU_2025查找最大元素
- Enum 类型
- linux僵尸进程的处理
- python cookbook(一) 文本
- 电商 Fab 或将进行新一轮大规模裁员
- qt中xml文件的简单读取
- 一个关于选择的小问题