2159,Ancient Cipher 用数组计数
2011-04-13 18:57
148 查看
#include<iostream>
using namespace std;
#include<math.h>
int main()
{
char a[105];
char b[105];
int coua[26],coub[26];
while(cin>>a)
{
cin>>b;
memset(coua,0,sizeof(coua));
memset(coub,0,sizeof(coub));
int len=strlen(a);
for(int i=0;i<len;i++)
{
coua[a[i]-'A']++;
coub[b[i]-'A']++;
}
int sign=0;
for(int i=0;i<26;i++)
{
for(int j=0;j<26;j++)
{
if(coua[i]==coub[j])
{
coub[j]=-1;
sign++;
break;//break十分重要别把后面一样的都给删了
}
}
}
if(sign==26)
cout<<"YES"<<endl;
else
cout<<"NO"<<endl;
}
return 0;
}
using namespace std;
#include<math.h>
int main()
{
char a[105];
char b[105];
int coua[26],coub[26];
while(cin>>a)
{
cin>>b;
memset(coua,0,sizeof(coua));
memset(coub,0,sizeof(coub));
int len=strlen(a);
for(int i=0;i<len;i++)
{
coua[a[i]-'A']++;
coub[b[i]-'A']++;
}
int sign=0;
for(int i=0;i<26;i++)
{
for(int j=0;j<26;j++)
{
if(coua[i]==coub[j])
{
coub[j]=-1;
sign++;
break;//break十分重要别把后面一样的都给删了
}
}
}
if(sign==26)
cout<<"YES"<<endl;
else
cout<<"NO"<<endl;
}
return 0;
}
相关文章推荐
- Poj 2159 / OpenJudge 2159 Ancient Cipher
- 【分治计数|单调栈】51Nod 1215 数组的宽度
- poj 2159 Ancient Cipher
- POJ-2159 Ancient Cipher
- 计数太麻烦,数组来帮忙
- 【树状数组】计数问题 @JSOI2009/upcexam5911
- poj 2159 Ancient Cipher(水)
- OC学习篇之---数组对象的引用计数问题和自动释放池的概念
- hdu 5701 中位数计数(重构数组)
- POJ 2159 Ancient Cipher(我的水题之路——双重加密)
- JQuery确定第一个参数在数组中的位置,从0开始计数(如果没有找到则返回 -1 )。
- POJ 2159 Ancient Cipher 解题报告
- POJ-2159-Ancient Cipher
- POJ 2159 Ancient Cipher
- POJ 2159 Ancient Cipher
- POJ 2159 Ancient Cipher(水题)
- Poj 2159 / OpenJudge 2159 Ancient Cipher
- POJ 2159 Ancient Cipher
- Google 2016 面试题6 | Count of Smaller Numbers After Self(数组计数)
- 字符串同构问题 字符串操作:数组计数字符个数问题