黄色网页视频 I 影音先锋日日狠狠久久 I 秋霞午夜毛片 I 秋霞一二三区 I 国产成人片无码视频 I 国产 精品 自在自线 I av免费观看网站 I 日本精品久久久久中文字幕5 I 91看视频 I 看全色黄大色黄女片18 I 精品不卡一区 I 亚洲最新精品 I 欧美 激情 在线 I 人妻少妇精品久久 I 国产99视频精品免费专区 I 欧美影院 I 欧美精品在欧美一区二区少妇 I av大片网站 I 国产精品黄色片 I 888久久 I 狠狠干最新 I 看看黄色一级片 I 黄色精品久久 I 三级av在线 I 69色综合 I 国产日韩欧美91 I 亚洲精品偷拍 I 激情小说亚洲图片 I 久久国产视频精品 I 国产综合精品一区二区三区 I 色婷婷国产 I 最新成人av在线 I 国产私拍精品 I 日韩成人影音 I 日日夜夜天天综合

SZU:A26 Anagram

系統 2810 0

Judge Info

  • Memory Limit: 32768KB
  • Case Time Limit: 10000MS
  • Time Limit: 10000MS
  • Judger: Normal

Description

An anagram is formed by rearranging the letters of a word. You are given a string, please find out if it is an anagram of a word or not. No word will have have more than 50 characters.

Input

The input will consist of a word on one line. The following line contains a number,?, of strings to be tested.

Output

For each test string, if the test string is identical to the source string, output 'IDENTICAL', if it is an anagram, output 'ANAGRAM' otherwise output 'NOT AN ANAGRAM', in a single line.

Sample Input

    cares

5

scare

races

cares

another

acres


  

Sample Output

    ANAGRAM

ANAGRAM

IDENTICAL

NOT AN ANAGRAM

ANAGRAM
  

?

?

?

解題思路:字符串數組排序,但是我的方法并不好,只是勉強解出來而已。不過學會了使用qsort函數。

      
         1
      
       #include <stdio.h>


      
         2
      
       #include <
      
        string
      
      .h>


      
         3
      
      
        char
      
       A[
      
        52
      
      
        ];


      
      
         4
      
      
        char
      
       B[
      
        52
      
      
        ];


      
      
         5
      
      
        char
      
       C[
      
        52
      
      
        ];


      
      
         6
      
      
         7
      
      
        void
      
       swap(
      
        char
      
       *a,
      
        char
      
       *
      
        b){


      
      
         8
      
      
        char
      
      
         t;


      
      
         9
      
           t=*
      
        a;


      
      
        10
      
           *a=*
      
        b;


      
      
        11
      
           *b=
      
        t;


      
      
        12
      
      
        }


      
      
        13
      
      
        14
      
      
        int
      
      
         main() {


      
      
        15
      
           scanf(
      
        "
      
      
        %s
      
      
        "
      
      
        ,A);


      
      
        16
      
      
        int
      
      
         n,flag,i,j;


      
      
        17
      
           scanf(
      
        "
      
      
        %d
      
      
        "
      
      ,&
      
        n);


      
      
        18
      
      
        for
      
       (i=
      
        0
      
      ;i<strlen(A);++
      
        i){


      
      
        19
      
               C[i]=
      
        A[i];


      
      
        20
      
      
            } 


      
      
        21
      
      
        while
      
       (n--
      
        ) {


      
      
        22
      
      
        23
      
               scanf(
      
        "
      
      
        %s
      
      
        "
      
      
        ,B);


      
      
        24
      
               flag=
      
        1
      
      
        ;


      
      
        25
      
      
        for
      
       (i=
      
        0
      
      ;i<strlen(A);++
      
        i) {


      
      
        26
      
      
        if
      
      (A[i]!=
      
        B[i])


      
      
        27
      
                       flag=
      
        0
      
      
        ;


      
      
        28
      
      
                }


      
      
        29
      
      
        if
      
      (flag==
      
        1
      
      ){printf(
      
        "
      
      
        IDENTICAL\n
      
      
        "
      
      ); 
      
        continue
      
      
        ;}


      
      
        30
      
      
        for
      
       (i=
      
        0
      
      ;i<strlen(C)-
      
        1
      
      ;++
      
        i) {


      
      
        31
      
      
        for
      
       (j=i+
      
        1
      
      ;j<strlen(C);++
      
        j) {


      
      
        32
      
      
        if
      
      (B[i]>
      
        B[j])


      
      
        33
      
                           swap(&B[i],&
      
        B[j]);


      
      
        34
      
      
        if
      
      (C[i]>
      
        C[j])


      
      
        35
      
                           swap(&C[i],&
      
        C[j]);


      
      
        36
      
      
                    }


      
      
        37
      
      
                }


      
      
        38
      
      
        39
      
      
        for
      
       (i=
      
        0
      
      ;i<strlen(A);++
      
        i) {


      
      
        40
      
      
        if
      
      (C[i]!=
      
        B[i])


      
      
        41
      
                       flag=
      
        2
      
      
        ;


      
      
        42
      
      
                }


      
      
        43
      
      
        if
      
      (flag==
      
        0
      
      ){printf(
      
        "
      
      
        ANAGRAM\n
      
      
        "
      
      ); 
      
        continue
      
      
        ;}


      
      
        44
      
      
        else
      
       printf(
      
        "
      
      
        NOT AN ANAGRAM\n
      
      
        "
      
      
        );


      
      
        45
      
      
            }


      
      
        46
      
       }
    

大神解法:

      
         1
      
       #include<stdio.h>


      
         2
      
       #include<stdlib.h>


      
         3
      
       #include<
      
        string
      
      .h>


      
         4
      
      
         5
      
      
        char
      
       S[
      
        55
      
      
        ];


      
      
         6
      
      
         7
      
      
        int
      
       cmp(
      
        const
      
      
        void
      
       *a,
      
        const
      
      
        void
      
       *
      
        b)


      
      
         8
      
      
        {


      
      
         9
      
      
        return
      
       *(
      
        char
      
       *)a-*(
      
        char
      
       *
      
        )b;


      
      
        10
      
      
        }


      
      
        11
      
      
        12
      
      
        int
      
      
         main()


      
      
        13
      
      
        {


      
      
        14
      
      
        int
      
      
         n,i,len1,len2;


      
      
        15
      
      
        char
      
       str[
      
        55
      
      ],temp[
      
        55
      
      
        ];


      
      
        16
      
           scanf(
      
        "
      
      
        %s
      
      
        "
      
      
        ,S);


      
      
        17
      
      
            strcpy(temp,S);


      
      
        18
      
           len1=
      
        strlen(S);


      
      
        19
      
           qsort(S,len1,
      
        sizeof
      
      (
      
        char
      
      
        ),cmp);


      
      
        20
      
           scanf(
      
        "
      
      
        %d
      
      
        "
      
      ,&
      
        n);


      
      
        21
      
      
        for
      
      (i=
      
        0
      
      ;i<n;i++
      
        )


      
      
        22
      
      
            {


      
      
        23
      
               memset(str,
      
        0
      
      ,
      
        sizeof
      
      
        (str));


      
      
        24
      
               scanf(
      
        "
      
      
        %s
      
      
        "
      
      
        ,str);


      
      
        25
      
               len2=
      
        strlen(str);


      
      
        26
      
      
        if
      
      (len2!=
      
        len1)


      
      
        27
      
      
                {


      
      
        28
      
                   printf(
      
        "
      
      
        NOT AN ANAGRAM\n
      
      
        "
      
      
        );


      
      
        29
      
      
        continue
      
      
        ;


      
      
        30
      
      
                }


      
      
        31
      
      
        if
      
      (
      
        0
      
      ==
      
        strcmp(str,temp))


      
      
        32
      
      
                {


      
      
        33
      
                   printf(
      
        "
      
      
        IDENTICAL\n
      
      
        "
      
      
        );


      
      
        34
      
      
        continue
      
      
        ;


      
      
        35
      
      
                }


      
      
        36
      
      
        else
      
      
        37
      
      
                {


      
      
        38
      
                   qsort(str,len2,
      
        sizeof
      
      (
      
        char
      
      
        ),cmp);


      
      
        39
      
      
        if
      
      (
      
        0
      
      ==
      
        strcmp(S,str))


      
      
        40
      
                       printf(
      
        "
      
      
        ANAGRAM\n
      
      
        "
      
      
        );


      
      
        41
      
      
        else
      
      
        42
      
                       printf(
      
        "
      
      
        NOT AN ANAGRAM\n
      
      
        "
      
      
        );


      
      
        43
      
      
                }


      
      
        44
      
      
            }


      
      
        45
      
      
        return
      
      
        0
      
      
        ;


      
      
        46
      
       }
    

?

?

SZU:A26 Anagram


更多文章、技術交流、商務合作、聯系博主

微信掃碼或搜索:z360901061

微信掃一掃加我為好友

QQ號聯系: 360901061

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。

【本文對您有幫助就好】

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描上面二維碼支持博主2元、5元、10元、自定義金額等您想捐的金額吧,站長會非常 感謝您的哦!!!

發表我的評論
最新評論 總共0條評論