poj2159Ancient Cipher
来源:互联网 发布:sem和seo区别 编辑:程序博客网 时间:2024/06/16 01:51
水题一道,然而废了不少功夫,频率一样就行,排个序就OK了,不过刚开始以为只能加1,其实可以加很多,题意理解错了
#include <iostream>#include <string.h>#include <algorithm>using namespace std;string s1,s2;int a1[150],a2[150];int main(){ while(cin>>s1>>s2) { int ans=0,k=1; for(int i=0; i<s1.length(); i++) { a1[i]=0; a2[i]=0; } bool flag=0; for(int i=0; i<s1.length(); i++) a1[s1[i]-'A']++; for(int i=0; i<s2.length(); i++) a2[s2[i]-'A']++; sort(a1,a1+30); sort(a2,a2+30); for(int i=0; i<=30; i++) { if(a1[i]==a2[i]) continue; else { flag=1; break; } } if(flag==1) cout<<"NO"<<endl; else cout<<"YES"<<endl;; for(int i=0; i<s1.length(); i++) s1.clear(); for(int i=0; i<s2.length(); i++) s2.clear(); } return 0;}
0 0
- POJ2159Ancient Cipher
- poj2159Ancient Cipher
- poj2159Ancient Cipher
- Cipher
- Cipher
- Cipher
- cipher
- Cipher Code
- 1026 Cipher
- EVP cipher
- Playfair Cipher
- 加密---Cipher
- Cipher-----置换
- Cipher(P1026)
- Ancient Cipher
- Cipher Message
- uva1339Ancient Cipher
- Cipher Message
- XDU-1032 找规律II (Lucas定理)
- HashMap实现原理分析
- Oracle 在Spring+Hibernate中的使用
- HDU 2063 过山车(第一发二分匹配)
- java集合11--HashTable源码详解
- poj2159Ancient Cipher
- 二叉树遍历方式总结
- Markdown 低频语法手册
- 解决一下华为手机选取相册照片,选取不到问题。
- 内存管理 ---slab机制 分配对象
- Android 导入第三方jar包
- 设计模式(6)--策略模式
- ZOJ-3868-GCD Expectation(容斥)
- Jquery Ajax 跨域调用asmx类型 WebService范例