UVA - 1339 Ancient Cipher
2015-10-11 07:47
375 查看
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
int i,j,len,num;
int cnt1[30],cnt2[30];
char st1[105],st2[105];
while(~scanf("%s",st1))
{
num=0;
scanf("%s",st2);
memset(cnt1,0,sizeof(cnt1));
memset(cnt2,0,sizeof(cnt2));
len=strlen(st1);
for(i=0;i<len;i++)
{
cnt1[st1[i]-'A']++;
cnt2[st2[i]-'A']++;
}
sort(cnt1,cnt1+26);
sort(cnt2,cnt2+26);
for(i=0;i<26;i++)
if(cnt1[i]==cnt2[i]) num++;
if(num==26) printf("YES\n");
else printf("NO\n");
}
return 0;
}
心得:昨天做的,题意很难懂,要不是看紫书根本想不出来。。。还有,第一次sort函数的使用,居然是快速排序,醉了。。。
#include <string.h>
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
int i,j,len,num;
int cnt1[30],cnt2[30];
char st1[105],st2[105];
while(~scanf("%s",st1))
{
num=0;
scanf("%s",st2);
memset(cnt1,0,sizeof(cnt1));
memset(cnt2,0,sizeof(cnt2));
len=strlen(st1);
for(i=0;i<len;i++)
{
cnt1[st1[i]-'A']++;
cnt2[st2[i]-'A']++;
}
sort(cnt1,cnt1+26);
sort(cnt2,cnt2+26);
for(i=0;i<26;i++)
if(cnt1[i]==cnt2[i]) num++;
if(num==26) printf("YES\n");
else printf("NO\n");
}
return 0;
}
心得:昨天做的,题意很难懂,要不是看紫书根本想不出来。。。还有,第一次sort函数的使用,居然是快速排序,醉了。。。
相关文章推荐
- 【bzoj2226】【spoj5971】【lcmsum】【数论】
- VS2010中“工具>选项中的VC++目录编辑功能已被否决”解决方法
- C++与类型转换相关的四个关键字及其特点
- Spring Boot实践应用开发(8)
- 2007年NOIP提高组 统计数字
- LeetCode Algorithms #100 <Same Tree>
- 2011年NOIP提高组 铺地毯
- 解析大型.NET ERP系统:十三种界面设计模式
- OSChina 周日乱弹 —— 旅游被宰后正确处理方式
- Lua入门
- codevs 1293 送给圣诞夜的极光
- 毕业5年决定人的一生(转)-- 大家千万不要错过这篇文章
- hdu5499 SDOI
- LeetCode Algorithms #237 <Delete Node in a Linked List>
- 为什么不能用memcached存储Session
- *LeetCode-Interleaving String
- LeetCode Algorithms #104 <Maximum Depth of Binary Tree>
- LeetCode Minimum Size Subarray Sum
- LeetCode Algorithms #290 <Word Pattern>
- 004 Conditionals In java JAVA中的条件句