poj2159

简单题

View Code
#include <iostream>
#include
<cstdlib>
#include
<cstring>
#include
<cstdio>
#include
<algorithm>
using namespace std;

char st1[106], st2[106];
int f1[27], f2[27];

void make(char *st, int *f)
{
gets(st);
for (int i = 0; i < strlen(st); i++)
{
if (st[i] >= 'a')
st[i]
-= 'a' - 'A';
f[st[i]
- 'A']++;
}
sort(f, f
+ 26);
}

int main()
{
//freopen("t.txt", "r", stdin);
memset(f1, 0, sizeof(f1));
memset(f2,
0, sizeof(f2));
make(st1, f1);
make(st2, f2);
bool ans = true;
for (int i = 0; i < 26; i++)
if (f1[i] != f2[i])
{
ans
= false;
break;
}
if (ans)
printf(
"YES\n");
else
printf(
"NO\n");
return 0;
}
原文地址:https://www.cnblogs.com/rainydays/p/2072820.html