#include <iostream>
#include <cstring>
using namespace std;
int main()
{
char a[101], b[101];//sirurile
int fa[127]={0}, fb[127]={0};//vectori de frecventa penrtu caractere
cin.getline(a,101);//citesc primul sir
cin.getline(b,101);//citesc cel de-al doilea sir
for(int i=0;i<strlen(a);i++)
fa[a[i]]++;//calculez frecventele
for(int i=0;i<strlen(b);i++)
fb[b[i]]++;//calculez frecventele
int ok=1;//presupun ca sunt anagrame
for(char c='a';c<='z';c++)//parcurg literele de la a la z
if(fa[c]!=fb[c])
ok=0;//frecvente diferite => nu sunt anagrame
if(ok) cout<<"DA";
else cout<<"NU";
return 0;
}
|