POJ-2159 Ancient Cipher
来源:互联网 发布:淘宝的广告位 编辑:程序博客网 时间:2024/05/21 23:31
#include <iostream>#include <stdio.h>#include <string.h>void srt(int* k){ int i; for(i = 0;i < 26-1;i ++) { int index=i; for (int j=i+1;j < 26;j ++) { if(k[j]<k[index]) index=j; } int l; l = k[index]; k[index] = k[i]; k[i] = l; }}using namespace std;int main(){ char s1[110],s2[110]; int k1[26],k2[26]; int i,t = 1; char s3[26] = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'}; while(scanf("%s",s1)!=EOF) { scanf("%s",s2); int len = strlen(s2); memset(k1,0,sizeof(k1)); memset(k2,0,sizeof(k2)); for (i=0 ; i<len ; i++) { for(int j = 0;j < 26;j ++) { if(s1[i]==s3[j]) k1[j]++; if(s2[i]==s3[j]) k2[j]++; } } srt(k1); srt(k2); for(i = 0;i < 26;i ++) { if(k1[i]!=k2[i]) { cout << "NO" << endl; t = 0; break; } } if(t == 1) cout << "YES" << endl; } return 0;}
/*这道题真是醉人。WA了几次,理解英文半天,排列是无规律的,替换也是无规律的。起初真的是按题目里说的字母+1什么的 也知道统计出现个数就行。但后来WA了之后重新读题 又错认为得按2,1,5,4,3这样排序 结果又大改。最后总结 题目真是够了...总耗时2个半小时就为了这道水题...再谈谈解法,就是统计s1 s2 2个字符数组每个字母出现的次数 字母不需要变化 统计就行 之后从小到大排序(顺便默写了一遍选择排序...)数量一一对应即可*/
0 0
- POJ 2159 Ancient Cipher
- poj 2159 : Ancient Cipher
- POJ 2159 Ancient Cipher
- POJ 2159 Ancient Cipher
- poj 2159 Ancient Cipher
- POJ 2159 Ancient Cipher
- POJ 2159 Ancient Cipher
- POJ-2159-Ancient Cipher
- POJ 2159 Ancient Cipher
- poj 2159 Ancient Cipher
- POJ 2159 Ancient Cipher
- POJ 2159 Ancient Cipher
- poj 2159Ancient Cipher
- POJ 2159 Ancient Cipher
- POJ 2159 Ancient Cipher
- POJ 2159 Ancient Cipher
- POJ-2159 Ancient Cipher
- poj 2159Ancient Cipher
- J2EE概述
- selenium By.xpath 用法
- 算法导论 第十八章;B 树
- 使用Python操作Redis
- vim文本编辑器主要内容
- POJ-2159 Ancient Cipher
- 失控--阅读笔记组装复杂性
- js this和$(this)区别
- UVALive - 3027 Corporative Network 并查集
- 多重继承与名字二义性
- window安装mysql方法图解
- tmux 常用
- 字符串 和 Unicode字符 的互转
- selenium webdriver学习(八)------------如何操作select下拉框