UVa 1339 Ancient Cipher(古老的密码)
来源:互联网 发布:js改变display样式 编辑:程序博客网 时间:2024/06/04 18:19
//由题意,字母间有对应关系,而且字符位置也可以随意变动//所以,直接对两个字符串中每个字母出现的次数排序,看看相同位置相不相等即可#include <stdio.h>#include <stdlib.h>#include <string.h>int sort(const void *a,const void *b){ return *(int *)b-*(int *)a;}int main(){ char s1[101]; char s2[101]; int number1[26]; int number2[26]; while(scanf("%s%s",s1,s2)!=EOF){ memset(number1,0,sizeof(number1)); memset(number2,0,sizeof(number2)); for(int i=0;s1[i];i++) number1[s1[i]-'A']++; for(int j=0;s2[j];j++) number2[s2[j]-'A']++; qsort(number1,26,sizeof(int),sort); qsort(number2,26,sizeof(int),sort); int flag=1; for(int i=0;i<26;i++){ if(number1[i]!=number2[i]){ flag=0; break; } } if(flag) printf("YES\n"); else printf("NO\n"); } return 0;}
1 0
- UVa 1339 Ancient Cipher(古老的密码)
- 例题 4-1 古老的密码(Ancient Cipher) UVa 1339
- 古老的密码(Ancient Cipher)
- 古老的密码(Ancient Cipher)
- UVA 1339 Ancient Cipher古老的密码【NEERC 2004】【刘汝佳紫书4-1】
- poj 2159 Ancient Cipher 古老的密码
- POJ 2159 Ancient Cipher(古老的密码)
- UVA 1339 - Ancient Cipher
- uva 1339 Ancient Cipher
- Uva - 1339 - Ancient Cipher
- UVA 1339 - Ancient Cipher
- UVa:1339 Ancient Cipher
- UVA 1339 - Ancient Cipher
- UVA-1339 - Ancient Cipher
- UVa 1339 Ancient Cipher
- UVa 1339 Ancient Cipher
- UVa 1339 - Ancient Cipher
- UVa 1339 - Ancient Cipher
- PHP面向对象_构造方法和析构方法
- C++ this指针的理解
- vim常用操作和使用技巧
- 【GIT】[Git高级教程 (一)] 通过Tag标签回退版本修复bug
- 正则表达式总结
- UVa 1339 Ancient Cipher(古老的密码)
- java面向对象的三大特性----封装、继承、多态
- Linux 平台下阅读源码的工具链
- hdu 4983 gcd与欧拉函数
- 消息机制--Handler
- 构建高并发高可用的电商平台架构实践
- HDOJ 1003 Java答案
- httpclient爬取网页
- VS2010下用C++编写图书管理小程序;(程序主要代码来自明日科技的书,但版本有差异,所以进行了部分调试和修改。)