uva 1339
来源:互联网 发布:windows下安装sublime 编辑:程序博客网 时间:2024/05/05 01:40
简单题, 计算出两个字符串中各个字母出现的频率,排序后对比一下即可
#include <iostream>#include <cstdio>#include <cstdlib>#include <algorithm>#include <string>#include <cstring> #include <vector>#include <set>#include <queue>#include <map>using namespace std;const int MAXN = 100 + 10;typedef long long LL;int main(){char oldstr[MAXN],newstr[MAXN];int oldcnt[26],newcnt[26];while( scanf("%s",newstr)!=EOF ){scanf("%s",oldstr);memset(oldcnt,0,sizeof(oldcnt));memset(newcnt,0,sizeof(newcnt));if( strlen(newstr)!=strlen(oldstr) ){cout << "NO" << endl;continue;}for(int i=0; i<strlen(newstr); i++){oldcnt[(oldstr[i]-'A')]++;newcnt[(newstr[i]-'A')]++;}sort(oldcnt,oldcnt+26);sort(newcnt,newcnt+26);int i;for(i=0; i<26; i++){if( oldcnt[i]!=newcnt[i] ) break;}if( i<26 ){cout << "NO" ;}else{cout << "YES";}cout << endl;} return 0;}
0 0
- UVA 1339
- uva 1339
- UVa 1339
- UVa 1339
- UVA-1339
- UVa 1339
- UVa 1339
- UVA 1339
- UVA 1339
- UVA 1339
- UVa 1339
- uva 1339
- UVA Ancient Cipher UVA - 1339
- UVA 1339 - Ancient Cipher
- uva 1339 Ancient Cipher
- Uva - 1339 - Ancient Cipher
- UVA 1339 - Ancient Cipher
- UVA 1339 - Ancient Cipherguo
- 深入学习Objective-C(二)理解 objc 关联对象 (Associated Objects)
- 将txt文件转换成pdf格式的两种方法
- git 回滚 远端库
- c# 正则表达式笔记
- 遍历jsonobject
- uva 1339
- Bouguet极线校正的方法
- Python操作Redis之订阅与发布
- 类的非静态成员函数指针详解
- FT232R假芯片之后我们怎么办
- 阿里云CTO章文嵩:GPU高性能计算是下一个风口
- Android中的JS交互小结
- eclipse使用
- 六款不容错过的开源持续集成工具