0 like 0 dislike
10.6k views

Write a function that tests whether two words or phrases are anagrams (permutations of the same letters):

寫一個判斷兩個單詞或詞組是不是符合易位構詞的函數。

#include <stdio.h>
#include <string.h>
#include <ctype.h>
int is_anagrams(char A[],char B[])
{
   /*INSERT YOUR CODE HERE*/


   /*END OF YOUR CODE*/
   //The function should return 1 if two words or phrases are anagrams, 0 if two words or phrases are not anagrams.
}

int main(void)
{
   char A[100],B[100];
   /*INSERT YOUR CODE HERE*/


   /*END OF YOUR CODE*/
   if (is_anagrams(A,B)) printf("Two words or phrases are anagrams");
   else printf("Two words or phrases are not anagrams");

   return 0;
}

Example input:

smartest
mattress

Example output:

Two words or phrases are anagrams

Example input:

dumbest
stumble

Example output:

Two words or phrases are not anagrams

Remember: You may correct the cases, but your code always be revised! 

[Exercise] Coding (C) - asked in Chapter 9: Functions
ID: 39986 - Available when: Unlimited - Due to: Unlimited
| 10.6k views
0 0
STRUPES!

79 Answers

0 like 0 dislike
Hidden content!
#include <stdio.h> ** *** * * ****** ** * * * **** *** **** ** *** ** *** ** * ** *** * * ** * **** ***** * ** * * * ** ** * **** * * * ** *** * *** **** * ** * * * ** * *** * * ** ** * *** **** ** * *** *** * ***** * ** ** ****** *** ** ** * ** * * ** ***** *** *** * * * * * * ** * *** * * * * **** ** * **** * * *** ** * ** ** * * ** *** **** **** * ** ** * * * ** * * ***** * * *** ** ***** ** * *** * ** *** * * * ** * *** *** * * * *** *** ** * ** * ** ** ** **** * * * ** * ** ** ** * ** ** ** ** * ** ** * * * ***** ** * *** * ***** * *** * ** **** * ****** * **** * ** *** * * ** * * * * **** * * ***** * * * * **** * **** * * * * * **** * * *** * * *** ** ** *** * * ** * * * * * * ** * ** * * * ** ***** *** **** ****** ** * *** * *********** ** *** ** * ** *** * * * * * * * * ***** * ** * * ** * *** *** * ** * ** * *** ** * ** ** * * * *** * * * * * * * *** * *** **** *** * ** **** **** ** * ** **** * * ** ** ** * *** * *** * * *** * ** * *** * ******* * * * * ** ** ** * ******* * *** ** ** *** ** * * ** ** ** **** ** * *** * *** *** * **** ***** ** * ** * * *** ** ***** ***** ** ** *** * ** ** *** ** ** ** ** * * ******* * *** **** ** * ** *** * * * * ** ** ** ****** **** * *** ***** * **** * * ****** * ** * * *** ** ** **** * ** * * * *** ** * ** ** * * * * * * * * * *** **** * * ** * * ** **** * *** *** * * * ***** *** * ******* * * ** *** ** ** * * * * * * * ** * ****** * * * *** * * * ** **** * * * * * * ** ** * * ** ** ** * ** * ***** ** ** * ** **** * * **** ** * ** ** * *** ****** ** **** * * * ** * ** ** ** ** * * * * *** ** *** ** * *** ** ** * * **** **** ** * ** ** * * * *** * * * * * * **** **** * ** *** * * *** *** * * ** * ** * ** * * ** * * *** * * * * * *** * * *** ** *** ** * ** * **** ** **** * * *** **** ** * ** ** ** * * ** *** ***** ** * * ** ** *** * *** ** ** **** * * * * * * **** ** ****** * * * ** * * * * * * * ** ** * *** * * * ** * * * * * ** *** **** * ** * * * * * *** * ** ** ** *** * * *** ** * *** * * * ** *** * ** *** ***** * * *** ** *** ** ***** * * ** * * ** * *** **** ** ** * **** ** * **** **** ** * * * ** * ** ***** ** ***** * * ***** * ** * ***** * * *** **** **** **** * ** * * ** * ****** ** ** ** * *** * * ** * ** *** **** ******* ** * ***** ** ** ** * ** ***** ** ** ** *** * * * *** * * ** *** * * * * **** *** * * * ** * * ********* ** * * * * * * * ** * ** ** ****** * * ** * ** * ** * * * ** ** *** *** ** * * * * * ** * * * ****** * *** ***** * * ** * ** by Elvis Suazo **** * * **** ****** * * * *** * **** ** ** ** ** * ******** ********** * * * **** **** * * ****** ***** *** * * * * * * * * * * *** * *** * ** * *** * * * ** *** * * ** * *** *** * * * ******* **** * ** * ** * * * * *** * * ** ** * *** * * ** ** ** * * ***** * *** * * ***** **** * ** * ** * * ** * * * * * * * **** * * * *** * * ** *** * * *** * * * * * ** * * * * * *** ** ** * * *** * * *** * *** * * ** ** ** * * ****** * ** *** ***** * *** *** * ** * ** * ** * * **** ** * **** * * * ** *** * **** *** * *** ***** *** * * * * ** ** * * * **** * ** * * ** * * * * ** *** * * ** * **** * * * * ****** * * * * ***** * * * * ** *** * * * ** * * * * ***** ** * ** * * **** * ** * * ** * ******* * * * ** * * * * * * ** * * * ** ** * *** ** **** * *** ** ** *** * * * ***** ** * * * ** ** * ** * * ** ** **** * ****** * * ** **** * ** * *** * *** ** **** ** * **** * ** ****** * ** ** ** *** * ** ** * * * ****** *** ** * * * ** * *** ****** * *** **** * ** ** * * ** * * *** **** *** * * * ** ** * * ** * * * ** * * * * * **** ******** ***** * * * *** ** * ** *** * * * * * ** **** * *** * * **** ** ** *** *** * * *** * ** * ** *** * ** ** * ******* * * *** ** * ** * ** * * ** * ** * * *** * * *** ** **** * * ***** ******* ** ** * ** ** * * * * ** ****** ** * * ***** * * * ** ** * *** * *** *** ** *** ****** ** *** ** * * * * * * * *** * ** * * ** * * * * ** *** ** * * ** * ** ** * * ***** * * ** ************ ***** * ** * *** **** ** *** ** ** * ** * ** * ** * * * **** * ** * * ** ** **** *** ***** * * *** ***** *** **** * * * * * **** ** **** ** * ** * **** * ** * * ** * * ***** * **** * * * * ** * *** ***** ** ** * ** * * * ** * * ** ** * * ** * * * ***** ******* ** ** ***** * * ****** ** ** * * * *** ** * ** ** **** * * *** ** * ****** * * * * *** * * **** * *** * * * * * * ** * ** * * * * **** *** * * * * * ** *** *** * *** ** ** * * * * * **** * * * * * * *** * * * ** * **** ***** * * * * * ** ** * ** * **** * * * * *** ** ***** * *** * ***** * ** ** * ****** * * ** **** * ** ** * ***** * *** * ** *** * * * * *** ** **** * * ** *** * *** * * * * * *** ** **** *** ** ** * **** * * *** * ** ** * * * ******* *** ** * * * by Elvis Suazo
#include <string.h>
#include <ctype.h>
int is_anagrams(char A[],char B[])
{
   /*INSERT YOUR CODE HERE*/

   if(strlen(A)!=strlen(B)){return 0;}

    int i,j;
    for(i=0;i<strlen(A);i++){
        for(j=0;j<strlen(B);j++){
            if(A[i]==B[j] && A[i]!='\0'){
* **** ** * ** ****** * * ** *** *** * * * *** ******* *** ** **** ** * * **** * ** * * * *** ** *
* *** * * * * * * * ** * * ****** *** * * ** ** * * * * * * * * ***

            }

        }

    }

    for(i=0;i<strlen(A);i++){
        for(j=0;j<strlen(B);j++){
            if(A[i]!=B[j] && A[i]!='\0'){
* * **** * ** * ** *** * * ******* ******* *** *** ** ***** * * **** ** ***** * ** ** ** 0;

            }

        }

    }

    return 1;
   /*END OF YOUR CODE*/
   //The function should return 1 if two words or phrases are anagrams, 0 if two words or phrases are not anagrams.
}

int main(void)
{
   char A[100],B[100];
   /*INSERT YOUR CODE HERE*/
    fgets(A,100,stdin);
    fgets(B,100,stdin);

   /*END OF YOUR CODE*/
   if (is_anagrams(A,B)) printf("Two words or phrases are anagrams");
   else printf("Two words or phrases are not anagrams");

   return 0;
}
answered by (-286 points)
0 0
Case 0: Wrong output
Case 1: Correct output
Case 2: Wrong output
Case 3: Wrong output
Case 4: Correct output
0 like 0 dislike
Hidden content!
#include <stdio.h>
#include <string.h>
#include <ctype.h>
int is_anagrams(char a[],char b[])
{
    int length=0,i,j,temp=0,k=0,l=0;
** * * *** * ****** ** ***** *
    for (i=0;i<length;i++)
*** ** * ** * * * *** ** ***** *

* * ** * ** * * * * ** * * ****** ** * * ** * * * ** ** ** (j=i;j<length;j++)
* *** *** * ** * ** ** ** * ** ** ** * * * *** * * ***** * ***
* * * *** ** ****** *** **** ** *** * ** * *** * ** *** ** ** * * ** ** *** ** * *** * * * ** * < a[i])
* *** * * ** ** * **** * * * * ** * ***** * ***** * * * **** * * ** * ****** * * * *** * *** ** **** * * ***
* * * * *** * * * *** ** * * ** *** ** ***** * * * ** * ** * *** * *** * * ** ** *** * * * * ** *** * * *** ** ***
*** ** * *** * ***** * * ** * *** **** ******* ** * * **** **** **** ** *** * * ** ** * ** * ** ********
** * ** * ***** *** *** ** **** * *** *** * * * ** ** ** ** ******* ** ****** **** ** *** * *** **
* ** ***** * ********* * *** * * * ********** *** * *** ***** ** * ** ****** * ** * ***** ** ** ***
** * * ** * * *** *** * ** * ** *** * **** * ***** * * * ** * *
* **** * **** * * ** *** * ** **
    for (i=0;i<length;i++)
**** ***** *** * * * *** * * ** ** ****
* **** ***** * * * *** ** * ** ** * ** * * * * ** ** * ** * (a[i]==32)
*** * *** **** ** ** ** * *** *** ** *** * * * * * *** *
** *** * * *** * * * * ** ** *** * * * * ** *** **** ** ** ** *** *** ***** * *
* ** **** * * ** *** * ** * * ** * * * * * ** * *** *
** * ** ** ** ** *** ***** * * * *** * * ** *
** * * *** **** ** * * * (i=0;i<length;i++)
    {
* * * **** **** ** * * **** *** ** *** * ** ** ** ** ***** **
    }

** ** * * ** *** * * * ** (i=0;i<length;i++)
* * ** * ******* ** * ********* *******
** **** *** * * * * * * ** ** * * * * *** ** **** *** ** (j=i;j<length;j++)
* ** * ** ** * ** ***** * * ***** *** *** * * *** **** * ***
**** *** ** * ** ** *** *** * *** * * * ** **** ** * * ** ******** ** * *** **** * *** **** ** ***** *** < b[i])
** * **** * **** * * * *** ** ** ** ** * * ** * ** ** * * * * * * * ** * *** ** * * *
**** ********** ** ** ** ** * ** ** ** ****** * **** ** * ** ** *** * ** * *** * ** * * ** * * ** * ** ** * *
** ** * * *** ****** *** * * ** * *** * *** * * * ** * ** * ** ** **** * **** ** * **** *** ** ** *** * **** *
* * *** ** * ** * * * * * * * * ***** *** ***** * ** ** * **** * * * ** * ** ** * **** ** ** * * ***
**** * * * * ** * ** ** * ** * * *** * * **** * ** ****** * * *** * ** *** *** * * ** * * ** * ** * **
* * * * * ** * ** * **** * * ******** * ** * ** * * ** * * * *
* ** ***** ***** * * ** * ** * * **** * **
** ** *** *** ** * ***** ** * ** *** * ** ** (i=0;i<length;i++)
*** * *** * * ****** * * * * *** ** * * *** * *
** *** * ** * * *** * * ** * ** ** *** * ****** * ******* **** * ** (b[i]==32)
* * * **** **** ** * * * * * * * * ** ** ** *** *
* * ** * * ** * *** * * ** ****** * ** ******** * * *** * * ** ** * *
* ** ****** ** * * * *** **** ** ** * * ** *** ** *** * * ** ***
* * *** * *** *** *** * ** ** * ** ** *
    for (i=0;i<length;i++)
    {
* *** ** * * ********* * * * ** ** * ** * *** *
    }
    if (strcmp(a,b)==0)
    {
**** ** *** * * * ** *** ** ** ** * ** * *** * **** 1;
    }
* ***** * * * * * *** *
    {
* ** ** * * *** **** * *** * ** **** ** * * 0;
    }
}

int main(void)
{
   char a[100],b[100];
* * *** *** ** * * ****** ** ***
* *** * *** * * ** * * *
   if (is_anagrams(a,b)) printf("Two words or phrases are anagrams");
   else printf("Two words or phrases are not anagrams");
   return 0;
}
answered by (-229 points)
edited by
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Wrong output
Case 3: Wrong output
Case 4: Correct output
0 0
Case 0: Wrong output
Case 1: Correct output
Case 2: Wrong output
Case 3: Wrong output
Case 4: Correct output
0 like 0 dislike
Hidden content!
#include ** ** ** *
#include ****** * * * **
#include * ** * ** **
int is_anagrams(char A[],char B[])
{
* * *** * * * * *** ** * **
** * * * *** *** * * * *
********* ***** *
* * * * ** * * * * *
* ** ** ** ** ***
* ** * * *** *
* ** * *** **
** * ** ** ** * *
* * * * ******
* *** * ****** * * * ***
*** * * * ** *
** **** *** * **
** ** ** * ** ***** *******
*** * ** *** ** * ** **
** **** * ***** **** 0;
** * ** * **** *
** *** ** *** * * ** *** 1;
}

int main(void)
{
* ** * ** **** A[100],B[100];
** * ***** ** * * * flag;
* * ****** * *** ** * ** * string :");
* *** ** * * * * ** * * * * * **
** ** * **** * *** * * ** * string");
** * ****** * ** *** * * * * * **
** *** * ** * ** ** * * * *
**** **** * ******* ** * (is_anagrams(A,B)) * ** *** * words or phrases are * *** * **
* * * *** * ** * * ** printf("Two words or phrases are not anagrams");

** *** ** **** ** 0;
}
answered by (16 points)
0 0
prog.c: In function 'main':
prog.c:30:12: warning: format '%s' expects argument of type 'char *', but argument 2 has type 'char (*)[100]' [-Wformat=]
    scanf("%s",&A);
            ^
prog.c:32:12: warning: format '%s' expects argument of type 'char *', but argument 2 has type 'char (*)[100]' [-Wformat=]
    scanf("%s",&B);
            ^
0 like 0 dislike
Hidden content!
#include <stdio.h>
#include <string.h>
#include <ctype.h>
int is_anagrams(char a[],char b[])
{
   int length=0,i,j,temp=0;
** *** * *** ** ** ** **
* * * **** * ** * (i=0;i<length;i++)
** ******* * *** * * ***** * ****
*** ** * *** * * * * * * ***** * * *** * *** * **** * * * (j=i;j<length;j++)
* * ** ** * ** * ****** * ** ***** **** ** ** *** * * ** *
**** * ** * ***** * ** ****** *** ** * * * * * *** ** * * *** * ** * * * **** * * * * ***** *** * < a[i])
* *** *** **** ** * ** * ***** * * * * ** *** ** * ** * ** ** **** * **** ** *** ** ** * * **
* * ** ***** ***** * * * * * ** * * ** * **** * * ** ** * ** * * * ** * * ** * ** * * *** *** ****
* ***** * ** * ** * *** * * * * * **** * ** * * ** ** **** ** * * * ****** *** * ** *** * ** * ** **** *****
* *** * * ** * ** *** *** ** * ** * * * * *** ** * * ***** * ** * ** ***** * ** * * ***** * * * **** * *
**** * * * *** * * * * * *** *** *** ** *** ****** ** *** ** ** ** **** * * * *** * *** * ** * **
** ****** * * ** * ** * * ****** * * * ** ****** **
* *** * ** * **** * ****** * * * * * * * * *
** **** * *** *** * * (i=0;i<length;i++)
* ** * * * * * **** ** ** * * ***** **** * * *** *
* **** ******* * * ** * * * * * * * ** *** **** * * ** *** * * * * (j=i;j<length;j++)
** ***** * *** * ** * * * * * ** ** ** ** *** * * *
** ** * * * * * * * * *** * ** **** * * * *** * * * *** * * * * * *** ** *** ** ****** ** * ** < b[i])
* * * * * **** * * ** * ** ***** ** ** * *** *** ** * * *** * *** ***** ***** ** *** ****** ** ** * ** *****
* * * * * ** * * ** *** **** * ** ***** ** * **** ** ** * * **** ** *** * * ****** **** * **** * * ******** ** **
** ** * *** * *** ** * **** **** * ****** ** * * * * * * * ** *** * * * * ***** ** ** *** * ** ** *** ****** *** *
* ** **** * ****** ** * ** ***** ** * ** * * ** *** ** * * * ** * * * * ** *** ** * **** ** * *** ** ** ****** **
** * * * * * * * ** * ******** * * * **** *** **** * * ** *** * *** * * * * ** ** * ** *** * **** * *
* * * ** * * *** * * ** *** * *** ***** ** * **** **
** *** * ** * ** **** * *** ** ** * *
*** *** * ** ***** * * ** ** ** (strcmp(a,b)==0)
    {
*** * **** * ** * * * * ** ****** ***** ***** * *** 1;
    }
* * * ** * *** **
    {
* * *** ** ** ***** **** * * ** ** * * * * 0;
    }
}

int main(void)
{
   int q;
   char a[100],b[100];
* *** * ** * * * %s",a,b);
   if (is_anagrams(a,b)) printf("Two words or phrases are anagrams");
   else printf("Two words or phrases are not anagrams");
   return 0;
}
answered by (-229 points)
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Wrong output
Case 3: Wrong output
Case 4: Correct output
0 like 0 dislike
Hidden content!
#include <stdio.h>

#include <string.h>

#include <ctype.h>

int is_anagrams(char A[],char B[])

{


* * **** * * ** letter,k=0;
*** *** *** * ** *** Acount[57]={};


* * ***** * * * * * ** * * * **** ** * * * ***
* * * * * * * *
* * ** * **** * *** ** * **** * *** *** * * ** **
** * ** * * *** * *** ** ******** * ** **
* * * ** * * * * **** * ** ** *** * * ** * * ** *** *
****** ****** ****** * * * * * * *** ** * * * * *** ** ** * ** * *** * ***


*** **** * ** *** * * ** ***** * * ** *
* ** * * * * * *


* * ** * * * *** *** ** * ** Bcount[57]={};


* * *** ** * **** ** * * * * ** * * **
* **** * * * * * *****
* * ****** * * * *** *** ** * ** ** *** ** ** *
**** * * **** * * * * ** **** ** * ** ***
* ** ** * ** * * * * *** * * ** * ** ** * * ** * * * * *** ** * *
*** * * * * * * * * ** * * * * ** ** *** ** ***** ****** **** ***** * *** *** * * * ***
* ** * * ** ** ** *** * *** * ** * ** *
* *** * ***** ** * ** **




* ** * ** ** ****** * *** *** i;
** * * * * * * ** * *
* *** * ** ** *
** * ** *** ** * * ******* * ** ** * ** * * * *
* ** * ** * ** ** * ** *** **** *** * * ** * * ****** * 0;
**** **** *** * * *** * ** *


* * ** *** * *** * * * 1;

}



int main(void)

{

   char A[100],B[100];

   int i;




* ** * * * **** * ** ** * ** * *** * **
* ** * *** ** *** * ** ********* ** *





   if (is_anagrams(A,B))
* * *** ***** * ** * * * **** words or phrases are anagrams");

   else
* ** * * *** * * ** * * *** *** words or phrases are not anagrams");



   return 0;

}
answered by (-16 points)
edited by
0 like 0 dislike
Hidden content!
#include <stdio.h>
#include <string.h>
#include <ctype.h>
int is_anagrams(char A[],char B[])
{

****** ****** * * *** * ** letter,k=0;
**** * * * * * *** Acount[26]={};

* * *** * ***** ** * ** ** * * **** ** *** * *** * *
** *** ** * * *** **
* * ** **** * ** * * ** ***** ** * ** *** * *** ** *
* **** * * ** * ******** ******** *** *** **** * *
*** * * * * * * **** ** * * * **** ** * * * *** * ** *
* * ** * ** * * ******* *** * * ** * ** ** * *** * * ** *** * * * ** * ** * ** *** *** * *

* * **** ****** *** ** * ***** *** * *** ****
    }

* *** * * **** * ** * * ****** * ** * * *** ** ** * * *
** * ** ** ** *
* * *** * * *** *** *** ** *** * * ** ** *** *** **
* * ** **** *** ** * ** **** ***
** *** * * * ***** * * * * * * * * * *** * * *** * * * **** * ***** ***
** * * **** ** * ** *** * ** *** * * * ** ** * * * ** ** * *** *** *** ***** * ***** ** * *

* * ** * *** * * ** * * **
    }

** *** * *** * ** *** * Bcount[26]={};

** * * ** ** * ** * **** * * * * * **** **
    {
* ** *** * * * * * *** * ** * ** * *** * ** * * ***
*** * * **** ** * *** * *******
*** ** **** ** ** * ** **** * *** *** ** * * * ** *** * * ** ** ** ** * *
** ** ** * ** * * *** * * * ** * ** ** ** ** * * *** * **** * * * * * * * *** * ** *
* * * * * *** * * ** *** ** ** * ** * *
    }

* * *** **** ** *** * * ** * * * * **** *
** * ****** * * * *
** ** * * ** * * ** * **** * ** * *** * ***
* **** ** * * **** *** *** ** * *** * *
* ** * * **** *** * ***** ** *** * * * * * ** * *** ** **** **
******* * **** * ** * ********** * ** **** * * * * * ** *** ***** ** ** * *** * *** * ***

** * ** ********* ** * **** ** **
    }


*** * * *** ** * i;
***** * ** **** **** *** * ** * *
    {
*** ** *** ** * * ** * * ******* ** *** * * *** **
* * * * ** **** * * *** * ** * * * ** * *** ** ** * ** * *** ** 0;
    }

** * * *** ** * * ** * *** 1;
}

int main(void)
{
   char A[100],B[100];
   int i;


* * * * * * * * * * * **
** * ** *** * * * * *


   if (is_anagrams(A,B))
** * * * * ** * * **** ***** words or phrases are anagrams");
   else
* **** ** *** ********* ** * ** words or phrases are not anagrams");

   return 0;
}
answered by (-16 points)
edited by
0 0
Case 0: Correct output
Case 1: Wrong output
Case 2: Wrong output
Case 3: Wrong output
Case 4: Correct output
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Wrong output
Case 3: Wrong output
Case 4: Correct output
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Wrong output
Case 3: Wrong output
Case 4: Correct output
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Wrong output
Case 3: Wrong output
Case 4: Correct output
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Wrong output
Case 3: Wrong output
Case 4: Correct output
0 0
Case 0: Wrong output
Case 1: Correct output
Case 2: Wrong output
Case 3: Wrong output
Case 4: Correct output
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Wrong output
Case 3: Wrong output
Case 4: Correct output
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output
Case 4: Correct output
0 like 0 dislike
Hidden content!
* * * * *** * ***
#include * * * *** *** *
** ** * * * **


int **** * *** A[],char B[])
{
int n1[26] = {0}, n2[26] = {0}, i=0 ;
int n=strlen(A);

**** * *** ***** ** i<n;i++)
*** **** * * *** ****
* *** * * ** * *** * * ** * **** **** * **
** * * ** * ** ****** * * ** ** - 'a']++;
* ** ****** ** ** ***
*** * **** i<n;i++)

* ** ** ** ** *
** * ** * * * * * ** ** *** ** * ***** * * * ** *** *******
** *** * ** * * * * * ** * *** *** * ** ****** -'a']++;
* ****** * ** ** * *
* * * * *** * ** ** * * (i = 0; i < 26; i++)
* * ** ******* ** ** *
*** *** *** * * * *** * *** * ** * (n1[i] != n2[i])
*** * ***** * * * ** *** * * ***** * *** *** *** ***** * * * * 0;
* ** * * ** *** **
* * ** * ** ***** * * * 1;
}

int main(void)
{
**** ** * * * * * A[100],B[100];
fgets(A, 100, stdin);
fgets(B, 100, stdin);
***** * * *** *
* ** **** * * * * ** ***
****** * *** ******* * * ***** words or phrases are * * * *
***** * ** * *
* * ** * * ** ** *** ** * * ** * * * * *** words or phrases are not * ** ** *

* * * * ******** ** ** 0;
}
answered by (323 points)
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output
Case 4: Correct output
0 like 0 dislike
Hidden content!
#include <stdio.h>
#include <string.h>
int main()
{
    int length=0,i,j,temp=0;
    char a[100],b[100];
* ** * **** ** * * *** *** ***** %s",a,b);
** * ** * * * ** * *** *** * ***
    for (i=0;i<length;i++)
* * *** * * * * * * * *** ** * ** **** * ****
** ****** **** * * * * ** * * ** * * ** ** *** * ** * ***** (j=i;j<length;j++)
* *** ** *** ***** *** **** * * ** * ** * ** * *** ** * * *
* * ** * ** *** * ***** *** * ** *** * *** *** * * *** * * * *** ** * * ** * **** ** ** * * ** **** * ** * *** < a[i])
*** * *** ** *** *** * ** **** ** *** ** * ** * *** *** * ** ** * *** ** ** ** * ** * * * ** *** * *** * ** *
*** * ** * *** *** ** * ** * * **** * ****** ** *** * * * ** *** *** ** ** ** *** ** * ***** * * ** *
**** ** ** * * *** *** ** * * * *** ** ** ******* *** *** * * * ** *** * ******* * * * **** * * * *
*** * *** *** * ** * * *** ** ** ** *** ** ** * ** ** * * * * ** * * * ****** * * ** *** * **** ** * *** ** *** ** * ***
* ****** * **** * * * * ** * * ** *** * * * * * * ***** ** ***** * * * * * ** * ***** ** **** ** * * * ****
** * * * * ** *** * ***** **** * * * *** ** ****** * ** ** * * **
* * *** * *** * * ****** ** * * * * * ****
     for (i=0;i<length;i++)
**** *** ** * * * * * **** ***** * *****
** *** ** *** * ***** * ******* * * ** ** * ** ***** * * ** * (j=i;j<length;j++)
***** * * * ***** ** * *** ** **** **** *** ******* ** * **** ****
* * * * *** * * * ** ********* * * ** * ** *** * ** * * * ** * *** * * ** * * * *** * ** < b[i])
* * * *** * ** ****** * ** ** * ** * * * * **** * * * ** **** **** ** ** * * *** * *
*** * * **** ** * ***** ** ***** * * * * * *** ******* ** ** ** * * ** * * * * **** ** ** *** * * * * *
* * ***** ** ** ** ** * *** ** * ** * * * ** *** *** ****** * * ** * * ** ***** *** ******* ** ** *** ** ** * *
* * * ** **** * * *** * ** * * *** ** ** * * * * * * *** * * ** ** * ******* ** * * *** * ***
* **** ** ******** * ****** * *** ** * *** *** *** ** * * * *** ** * *** * ** ** * * * * * * ****
* ** * * ** * *** * ** * *** ** * **** *** ******* **** **
** *** * ** ** *** ***** ** * * * * ** * ***
    if (strcmp(a,b)==0)
    {
* ** * * * ** ** ******* * **** **** * ** * * ** ** words or phrases are anagrams");
    }
    else
    {
**** **** ** * * *** * * * *** * * * * * ** **** words or phrases are not anagrams");
    }
    return 0;
}
answered by (-229 points)
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Wrong output
Case 3: Wrong output
Case 4: Correct output
0 like 0 dislike
Hidden content!
#include ** * * * * ***
#include *** * * * ***
#include ** *** *
int is_anagrams(char A[],char B[])
{
***** * ** ** * * YOUR CODE HERE*/
* * *** * * ** * a[26]={0};
* ** * * * * * b[26]={0};
** * * ** * ** * i;
** ** * * ** * *** ** **** ** * * ** *
*** * ** * * * * ** *
* * * * * *** ** ** * ** * * * * ****** ** * * * * * *** ***** && A[i]<='z')
** * ** ** * * * *** * * *** * * ** ** * ** *** * * * ** ** * * * ****** ** ** **
* * *** * * * ** ** * * ** ** **** ** * *** ** * ** * if (A[i]>='A' && A[i]<='Z')
*** ** * * ** * *** *** ** * *** ** ** * *** ** * ** * * ** ** * * * * * ** ***
** **** * *** ** * ** * * *
* ** * * *** *** ***** ****
* * ** *** * * *** *
** ** ** * *** * **** * * * * ** * ** * ** **** *** * ** && B[i]<='z')
** * **** * * ****** *** *** **** * ***** * ** ** ***** ** * ** *** **** * * *** ****
* * * ******* * **** * * * * **** ******** * * if (B[i]>='A' && B[i]<='Z')
* *** **** * ******* ******* *** * * ***** * * * * *** ***** * **** * * *** **
** ** ****** *** ** ****
* * ** *** ** * * * ** * ** *
**** *** * * * ** * ** * **
***** * * ****** ** ** * * * *** * * *** * ** * * * *
* ** ** ** * * * ** * * * *** * *
* ** * * *** ** * * ** * ** * * * * * ** * ** * ** * * * ** 0;
* * ** * * * ** ** * * ***** * * **** ** * * *
*** ** ** * *** * *


** * * * * ** ****** ** * 1;

* ** * * ** *** * OF YOUR CODE*/
* *** ***** ***** function should return 1 if two words or phrases are anagrams, 0 if two words or phrases are not anagrams.
}

int main(void)
{
* ** ** ** * * *** A[100],B[100];
** ** **** ********** * YOUR CODE HERE*/
** * * ** ** *** * ** * * %s",A,B);



** ** ** * * ** * ** OF YOUR CODE*/
* * * * * ** * (is_anagrams(A,B))
* **** * **** * * * * * ***** * *** words or phrases are * * *** ****
************ ** ** * * **
** ** ** * * * * ** *** ** ** **** **** * words or phrases are not * ** ***

** * *** *** * *** * 0;
}
answered by (-32 points)
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Wrong output
Case 3: Wrong output
Case 4: Correct output
0 like 0 dislike
Hidden content!
* * ** * * ****
** * ***** ***
*** * ** *** * *** **
int ** * * * * B[])
{
** ** ** *** int * * = {0};

* ****** int * ** = {0};

* * ** * *** int ** = ** *

** * * ** int ** = ****

* * * *** *** i = 0; i *** * *
* * ** * * ** {
**** * *** * * *** **** A[i] = *** * *

* * **** ** ** * *** * - *
** * * ***** * }

* ** ** ** * * * i = 0; i * * * i++)
* * * ** * * ** {
* * *** ** ** B[i] = ** *

** ***** * ** * * * * * -
* * * * }

** *** * * * * ** i = 0; i ** 26; i++)
*** *** ** * {
* *** * * *** **** * * * ** != * *
** * ** ** *** * **** {
***** * ** * ** * * * * * ** * * 0;
* ***** * * ** * ** }
* * * * ** }
** ** * **** ** 1;
** * *** **** ** * * ** ** **** ** * * * * * 1 if two * or ***** are * *
**** * * * //0 if two * or * * are not ***
}

int ** *
{
* ** ***** * * * * ** ** **
* * * ** * *
*** * * *** 100, **

*** * ** * ** * 100, * *

******** **** * * * * *** *** * * * or are ** * ** ***
* * *** * * ** * * * *** * * or * are not **** * * ****

**** *** *** ** *** 0;
}
answered by (-285 points)
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output
Case 4: Correct output
Welcome to Peer-Interaction Programming Learning System (PIPLS) LTLab, National DongHwa University
English 中文 Tiếng Việt
IP:172.70.126.150
©2016-2025

Related questions

0 like 0 dislike
47 answers
[Exercise] Coding (C) - asked Dec 7, 2017 in Chapter 9: Functions by semicolon (5.2k points)
ID: 35785 - Available when: 2017-12-07 18:00 - Due to: Unlimited
| 5k views
0 like 0 dislike
45 answers
[Exercise] Coding (C) - asked Dec 7, 2017 in Chapter 9: Functions by semicolon (5.2k points)
ID: 35784 - Available when: 2017-12-07 18:00 - Due to: Unlimited
| 5.6k views
0 like 0 dislike
41 answers
[Exercise] Coding (C) - asked Dec 14, 2017 in Chapter 9: Functions by semicolon (5.2k points)
ID: 37370 - Available when: 2017-12-14 18:00 - Due to: Unlimited
| 4.7k views
12,783 questions
183,442 answers
172,219 comments
4,824 users