poj 2503 Babelfish
来源:互联网 发布:tsis交通仿真软件 编辑:程序博客网 时间:2024/06/06 05:06
一个简单的单词翻译的题,我是使用字典序做的;
由于输入的问题 ,,WA,WA,,,
都是泪;
#include <iostream>#include <string.h>#include <stdio.h>using namespace std;struct node{ int chile[26]; bool qq; char uu[11]; node() { qq=0; memset(chile,0,sizeof(chile)); memset(uu,0,sizeof(uu)); }}t[300001];int index=1;void show(char *s,char *w){ int len=strlen(s); //int len1=strlen(s); int u=0; //int e; for(int i=0;i<len;i++) { int e=s[i]-'a'; if(t[u].chile[e]==0) {t[u].chile[e]=++index;} u=t[u].chile[e]; } //t[u].qq=1; strcpy(t[u].uu,w); //int o=u; //for(int j=u+1;j<u+len1;j++) //{ // int y=r[j-u-1]-'a'; // if(t[u].chile[y]==0) // { // t[j].chile[y]=sz++; // } // o=t[j].chile[y]; //} //t[0].qq=1;}void find(char* p){ int rr=0; int len=strlen(p); int g; for(int i=0;i<len;i++) { g=p[i]-'a'; if(t[rr].chile[g]==0) { printf("eh\n"); return ; } rr=t[rr].chile[g]; } printf("%s\n",t[rr].uu);}int main(){ char str[30],w[30],s[30]; int t; while(gets(str),str[0]) { //memset(s,0,sizeof(s)); int pos=0; //t=strlen(str); while(str[pos++]!=' '); str[pos-1]=0; //for(int i=0;i+pos<t;i++) // s[i]=str[i+pos]; memcpy(w,str,pos-1); show(str+pos,w);//把str+pos用数组代替就WA了。。。。<img alt="大哭" src="http://static.blog.csdn.net/xheditor/xheditor_emot/default/wail.gif" /> } while(gets(str)) find(str); return 0;}
0 0
- poj 2503 Babelfish
- POJ 2503 Babelfish(HASH)
- poj 2503 Babelfish
- POJ 2503 Babelfish
- POJ 2503 Babelfish
- poj 2503 Babelfish
- POJ 2503 Babelfish
- poj 2503 Babelfish 【hash】
- poj 2503 Babelfish【trie】
- POJ 2503 Babelfish
- poj-2503 Babelfish
- poj-2503 Babelfish
- poj 2503 Babelfish
- poj 2503 Babelfish
- POJ 2503 Babelfish
- POJ 2503 Babelfish (Hash)
- POJ 2503 Babelfish
- poj 2503 Babelfish(二分)
- ios开发中数据库读取数据牵涉到的日期处理:前一天、今天、后天、一周等
- 【Unity 3D】学习笔记三十八:角色控制器
- POJ 1631 Bridging signals
- POJ 2533 Longest Ordered Subsequence DP
- 加载lib文件技巧
- poj 2503 Babelfish
- 【ACM训练计划】POJ 题目分类 【初级、中级、高级】
- 组合数模版 整理
- scanf("%*d");
- 迪杰斯特拉--- 模板(求最短路径/输出路径/所有路径都可以走的做法)
- 最大概率法分词及性能测试
- Struts2如何传值到jsp页面
- tomcat启动startup.bat一闪而过
- 学习笔记 较全的php数组操作方法