Ananagrams hoj 字符串模拟
来源:互联网 发布:电子商务模拟教学软件 编辑:程序博客网 时间:2024/05/05 15:45
/*一道比较水的字符串模拟。刚开始的时候题意有点看错了。就是注意在有重组可以相同的字符串的时候要把原有的字符串也删除掉。这里用标记。只要将每个字母重排就可以了。还有大小写并没有区分在匹配的时候。*/#include <iostream>#include <stdio.h>#include <cstring>using namespace std;char a[1001][21];char b[1001][21];int main(){ char s[22]; char temp1[22]; scanf("%s",s); int h=0; strcpy(a[h],s);//a作为原来的数组 char c; for(int i=0; i<strlen(s); i++) { for(int j=i; j<strlen(s); j++) { if(s[i]>s[j]) { c=s[i]; s[i]=s[j]; s[j]=c; } } } strcpy(b[h],s); h++; while(scanf("%s",s)==1) { if(s[0]=='#') break; strcpy(temp1,s); for(int i=0; i<strlen(s); i++) { if(s[i]>='A'&&s[i]<='Z') s[i]=s[i]+32; } for(int i=0; i<strlen(s); i++) { for(int j=i; j<strlen(s); j++) { if(s[i]>s[j]) { c=s[i]; s[i]=s[j]; s[j]=c; } } } bool ret=0; for(int i=0; i<=h-1; i++) { if(strcmp(s,b[i])==0) { ret=1; a[i][0]='*'; break; } } if(ret==0) { strcpy(a[h],temp1); strcpy(b[h],s); h++; } } char te[22]; for(int i=0; i<h; i++) { if(a[i][0]!='*') { for(int j=i; j<h; j++) { if(a[j][0]!='*') { if(strcmp(a[i],a[j])>0) { strcpy(te,a[i]); strcpy(a[i],a[j]); strcpy(a[j],te); } } } } } for(int i=0; i<h; i++) { if(a[i][0]!='*') printf("%s\n",a[i]); } return 0;}
- Ananagrams hoj 字符串模拟
- UVA 156 Ananagrams (字符串模拟)
- hoj 1201 Ananagrams
- UVA 156 Ananagrams 模拟+字符串处理
- uva 156 Ananagrams(字符串模拟搜索)
- UVA 156 Ananagrams 模拟+字符串处理
- hoj Excuses, Excuses! 字符串模拟
- UVA156 Ananagrams(字符串处理)
- Ananagrams
- Ananagrams
- Ananagrams
- Ananagrams
- hoj 5311 字符串,dfs
- 487-3279 hoj 模拟AC
- HOJ 1017 模拟约瑟夫问题
- uva 156 Ananagrams(字符串+STL应用)
- HOJ 10411 字符串的修改
- 【基础练习】【模拟map练习】Uva156 - Ananagrams题解
- CvFileStorage结构的使用
- C/C++ 各种计时函数总结
- 关于Reactor handle_events( ACE_Time_Value * max_wait_time ) 的一个小细节问题
- Sicily 1527. Tiling a Grid With Dominoes
- 佛语
- Ananagrams hoj 字符串模拟
- HDU-1754-I Hate It
- log4j 学习记录
- Android 近百个项目的源代码,覆盖Android开发的每个领域
- STL:next_permutation (UVaOJ 146)
- 数据挖掘领域的十大经典算法
- 网页的色彩搭配
- 去掉博客首页任意部位的代码
- intellij+grails