UVA1339(字母映射)

memcmp(const void *buf1, const void *buf2, unsigned int count)可以比较两个串相等

http://baike.baidu.com/link?url=moP6BHDBs7PfCbVKaICYTP9biwBKdYjBfy2Raz45kwLx1SfvaccbGrFqmuwEOLDcc--3F9i81RiKA16NT74Ki_

其中count是内存大小,不是数组大小,要用sizeof()得出

#include <iostream>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <stack>
#include <cctype>
using namespace std;

#define mem(a,b) memset(a,b,sizeof(a))
#define pf printf
#define sf scanf
#define spf sprintf
#define debug printf("!
")
#define INF 10000
#define MAXN 5010
#define MAX(a,b) a>b?a:b
#define blank pf("
")
#define LL long long

char a[110],b[110];
int ac[26],bc[26];

int main()
{
     while(~sf("%s%s",a,b))
     {
          int i,j;
          mem(ac,0);
          mem(bc,0);
          int al = strlen(a);
          int bl = strlen(b);
          if(al!=bl)
          {
               puts("NO");
               continue;
          }
          for(i=0;i<al;i++)
          {
               ac[a[i]-'A']++;
               bc[b[i]-'A']++;
          }
          sort(ac,ac+26);
          sort(bc,bc+26);
          if(!memcmp(ac,bc,sizeof(ac)))
               puts("YES");
          else
               puts("NO");
          mem(a,0);
          mem(b,0);
     }
}
原文地址:https://www.cnblogs.com/qlky/p/5173561.html