[HDOJ]problem_1075【What Are You Talking About】
2014-07-18 13:40
405 查看
[HDOJ]problem_1075【What Are You Talking About】:
点击打开链接
刚开始没有加getchar();第二个START后面会有个空行,一直不明白为什么。后来问了学长才知道原来回车只是作为%s结束的标志,后面的gets(str3);会把回车吃掉。哈哈……还真是一个细小的问题,虽然细小,还是值得注意的
点击打开链接
#include<iostream> #include<cstdio> #include<map> #include<cstring> #include<string> #include<algorithm> using namespace std; int main() { map<string,string> str; map<string,string> ::iterator pos; int i,j,n,t,r,k; char s1[30],s2[30],s3[3005]; while (scanf("%s",s1)&&strcmp(s1,"START")!=0); while (scanf("%s",s1)&&strcmp(s1,"END")!=0) { scanf("%s",s2); str[s2]=s1; } while (scanf("%s",s1)) { if (strcmp(s1,"START")==0) break; } getchar(); //****** while (gets(s3)) { if (strcmp(s3,"END")==0) return 0; r=0; for (i=0;i<strlen(s3);i++) { if (s3[i]>='a'&&s3[i]<='z') { s1[r++]=s3[i]; } else { s1[r]='\0'; r=0; if (str.find(s1)!=str.end()) cout<<str[s1]; else cout<<s1; printf("%c",s3[i]); } } printf("\n"); } return 0; }
刚开始没有加getchar();第二个START后面会有个空行,一直不明白为什么。后来问了学长才知道原来回车只是作为%s结束的标志,后面的gets(str3);会把回车吃掉。哈哈……还真是一个细小的问题,虽然细小,还是值得注意的
相关文章推荐
- HDOJ.1075 What Are You Talking About(map)
- Hdoj 1075 What Are You Talking About 【MAP】
- HDOJ 1075 -- What Are You Talking About Trie( STL )
- ACM--火星文--HDOJ 1075--What Are You Talking About--map
- hdoj--1075 What Are You Talking About(Trie or map)
- HDOJ 1075 What Are You Talking About(字典树)
- HDOJ/HDU 1075 What Are You Talking About(字符串查找翻译~Map)
- HDOJ/HDU 1075 What Are You Talking About(字符串查找翻译~Map)
- HDOJ 1075 What Are You Talking About(trie树入门)
- hdoj 1075 What Are You Talking About 【STL map+string】
- hdoj1075 What Are You Talking About(STL map处理字符串)
- HDU/HDOJ 1075 What Are You Talking About(字典树|STL map)
- HDOJ 1075 What are you talking about ? 字典树
- [HDOJ1075]What Are You Talking About
- 【HDOJ】1075 What Are You Talking About
- hdoj1075 What Are You Talking About
- HDOJ 1075 What Are You Talking About
- HDOJ 1075 (What Are You Talking About)
- HDOJ 1075 What Are You Talking About
- HDOJ 1075 What are you talking about (map + 字符串 )