zoukankan      html  css  js  c++  java
  • 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);
         }
    }
  • 相关阅读:
    并查集
    关于一些位运算的小记
    用ST解决RMQ问题
    寒假作业_4
    H
    卢卡斯 组合数
    并查集
    G
    F
    E
  • 原文地址:https://www.cnblogs.com/qlky/p/5173561.html
Copyright © 2011-2022 走看看