0 like 0 dislike
10.4k views
Show more...
[Exercise] Coding (C) - asked in Chapter 9: Functions
ID: 39986 - Available when: Unlimited - Due to: Unlimited
| 10.4k views
0 0
STRUPES!

79 Answers

0 like 0 dislike
Hidden content!
#include ** *** ** *
#include * ** * * *
#include * ** * * ** ***
int * * ** a[],char b[])
{
* * *** * * ***** * first[26] = {0}, second[26] = {0}, c = 0;
* * *
*** ***** * ** ** * frequency of *** * in first string
** ***
* * * *** *** (a[c] != '\0')
* * ***** *** *
* ****** ** * * * ** ** * ** ** ** ** **
* *** * **** * ** ********* *
*** * * * * *
***
***** *** ** ** = 0;
* *
** * * * * (b[c] != '\0')
* *** * * ***** *
* ** *** *** * ****** * * ** * * *** * ** *
** * ***** * *** * * * * * **
*** * * ********* *
* **
***** * * ** Comparing frequency of ***
* ****
* ** ***** * (c = 0; c < 26; c++)
* * * * * ** ***
* * ** * * * ** ** **** * * * * (first[c] != second[c])
*** **** * * * * **** * *** * ** * * * *** * 0;
* * * ** *****
**** * *
* ***** * *** * * 1;
}

int * ***
{
* ** ** * * ** **** *
* * ** * ** **** * *** *** * A,B);
** * * * ** ** *** * * * ** * * * words or phrases are **** * ****
* * ** ** ** ***** * *** ** * words or phrases are not * * * *

* * * **** **** * 0;
}
answered by (-249 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 * ******* a[],char b[])
{
* ** * ** * * first[26] = {0}, second[26] = {0}, c = 0;
***
* * ** * * * ***** frequency of characters in first string
**** **
* * * ** * ** * * *** (a[c] != '\0')
* * * *** ** *
*** * * ** *** *** *** **** ** ** * * * ** ***
** ** ** * ** *** *** * ******** **
*** * *
** **
* ** * * ******* = 0;
*** **
** ***** * * * * (b[c] != '\0')
******** ** * ** ***
*** ***** * *** * * * ** *** ** ** ** *
** * **** **** * ** *** * **** *
* ** **** ****
* * *
* * * ** *** * Comparing frequency of *** * *
**** *
** ** ** * ** ***** (c = 0; c < 26; c++)
* * * * * *
* * ** * * * ** * * * * *** ** *** (first[c] != ***
* ** ** * * **** ****** ** ** ** ** ******* 0;
* **** **** *****
* ****
** ** ** *** *** * 1;
}

int main(void)
{
*** * ** *** ****** *
**** ** * * ** * *** * ***** * * *** *** *
* * * * ** *** * ** ** ** * **** * ** * words or phrases are * * ***
*** * **** ** ** *** * *** * words or phrases are not ** ** ** ***

* * * * * * ** * 0;
}
answered by (-249 points)
0 0
prog.c: In function 'main':
prog.c:38:12: warning: format '%s' expects argument of type 'char *', but argument 2 has type 'char (*)[100]' [-Wformat=]
    scanf("%s %s", &A,&B);
            ^
prog.c:38:15: warning: format '%s' expects argument of type 'char *', but argument 3 has type 'char (*)[100]' [-Wformat=]
    scanf("%s %s", &A,&B);
               ^
0 like 0 dislike
Hidden content!
#include * ** ***
#include * * ** ** *
#include * * ** * ** *
int is_anagrams(char A[],char B[])
{
*** * * * * * * ** YOUR CODE HERE*/
** * ** ***** **** *** ****
* * **** * * ** ** ** ** * * * **
**** * * *****
* *** * * * ** * * * **** ** ** * * * * * * * ** * ** && * ******** ***** **
* * *** ******* *** *** * * * *** * ** * *** * * ** * **** * ******
* * ** * ** * ** ***** * ** *** * * * **** * * *** * ** * && * * * **
*** * * ** **** **** * ** * * * * * **** *** ** ** * * *** *
* * * * * ** **
** * *** * **** ** * ***** **
* *** * * ****** ** **
* ***** *** * ** *** * * ******* * * *** * (cA[i]!=cB[i])
** * ** ** *** * * * * * * *** ** ** ** ** ** * * * ** *** ** ** 0;
** *** ** * **** **
* * * ** **** ** ***** 1;
* *** * * ** ********* OF YOUR CODE*/
*** * ** * * function should return 1 if two words or phrases are anagrams,
**** * ** **** * ** if two words or phrases are not anagrams.
}

int main(void)
{
* **** * *** * ** ** A[100],B[100];
** ***** * ** * * YOUR CODE HERE*/
*** ** **** ** ** ***** *** ** *
** * * **** ** ** ***** * * ***
* ** ** * ** ** * ***** * (is_anagrams(A,B))
** ** ** * ** * *** * * * ***** *** *** ****** * ** words or phrases are anagrams");
*** * ** * * * *** ****
* ** * *** *** ***** * * * ** *** * * ** * ******* * * ** * * words or phrases are not anagrams");
* ** * * ** *** * ** 0;
** ** * **** * ** OF YOUR CODE*/
}
answered by (-249 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
prog.c: In function 'main':
prog.c:50:5: warning: implicit declaration of function 'fgets' [-Wimplicit-function-declaration]
     fgets(A,888,stdin);
     ^~~~~
prog.c:50:17: error: 'stdin' undeclared (first use in this function)
     fgets(A,888,stdin);
                 ^~~~~
prog.c:50:17: note: each undeclared identifier is reported only once for each function it appears in
prog.c:53:27: warning: implicit declaration of function 'printf' [-Wimplicit-function-declaration]
     if (is_anagrams(A,B)) printf("Two words or phrases are anagrams");
                           ^~~~~~
prog.c:53:27: warning: incompatible implicit declaration of built-in function 'printf'
prog.c:53:27: note: include '<stdio.h>' or provide a declaration of 'printf'
prog.c:54:10: warning: incompatible implicit declaration of built-in function 'printf'
     else printf("Two words or phrases are not anagrams");
          ^~~~~~
prog.c:54:10: note: include '<stdio.h>' or provide a declaration of 'printf'
0 0
prog.c: In function 'main':
prog.c:50:5: warning: implicit declaration of function 'fgets' [-Wimplicit-function-declaration]
     fgets(A,888,stdin);
     ^~~~~
prog.c:50:17: error: 'stdin' undeclared (first use in this function)
     fgets(A,888,stdin);
                 ^~~~~
prog.c:50:17: note: each undeclared identifier is reported only once for each function it appears in
prog.c:53:27: warning: implicit declaration of function 'printf' [-Wimplicit-function-declaration]
     if (is_anagrams(A,B)) printf("Two words or phrases are anagrams");
                           ^~~~~~
prog.c:53:27: warning: incompatible implicit declaration of built-in function 'printf'
prog.c:53:27: note: include '<stdio.h>' or provide a declaration of 'printf'
prog.c:54:10: warning: incompatible implicit declaration of built-in function 'printf'
     else printf("Two words or phrases are not anagrams");
          ^~~~~~
prog.c:54:10: note: include '<stdio.h>' or provide a declaration of 'printf'
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output
Case 4: Correct output
0 0
-----------Re-judge-----------
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct 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: Correct output
Case 3: Correct output
Case 4: Correct output
0 like 0 dislike
Hidden content!
#include <stdio.h>

int is_anagrams(char A[],char B[])
{
*** ** * *** ** ** *** * Array1[26] = {0}, Array2[26] = {0}, i = 0;
* * ****** * ****
* ** ***** ** ** ****** ** * (A[i] != '\0')
* * ** * ** * * * **
* * **** ******* * * * ** * * **** ** *
* * **** * *** ** * ** *** ** ******** * **
* ** **** **** ** ***
* *** * * ** * *
** * * * * * * *** ** = 0;
**** ** * * * * * *** *
**** ** * * * **** (B[i] != '\0')
**** **** **** ** *
* ** * * * * ****** * ** *** **** * ***** * *
* **** ** * * * ** * * * * *** ** * ******* ** *
* *** ** ******** **
    
****** * * * * * * *** (i = 0; i < 26; i++)
*** * * ** *** *
****** * ** *** * * ** ** ** * ** * ** **** * (Array1[i] != Array2[i])
* * * ** **** ** * * * *** * ****** **** * * **** * *** * ** 0;
* * ** * * * **** * * * ***
* ********* *** * *
* * **** **** **** * 1;
}

int main()
{
* **** * * ** *** * * *** * A[100],B[100];

** * **** *** * * *** * ** **** * *
** ** **** * ** *** ** * *
***** * * * **** ***
* * ***** * *** ** * *** (is_anagrams(A,B))
* * ** *** ** ** ** *
* * * ** * * ** * * ********* * * ** ** *** **** ** ********* words or phrases are anagrams");
****** * * ** **
* * * *** * *** ** ** printf("Two words or phrases are not anagrams");
* * ** * *** *** **
** * *** ** * ** * * 0;
}
answered by (-193 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>

int is_anagrams(char A[],char B[])
{
*** * ** * * ** * * ** * Array1[26] = {0}, Array2[26] = {0}, i = 0;
* ** * *** * * ***
** *** ** * * (A[i] != '\0')
* * * * * ** *** *** ** *
*** ** ** ** * * * ** * *** * ** * ** **** *****
** * ** ***** *** ** **** *** * * * * * **
** * * * * * ** * * *
* * * ** *** **
* * ** ** *** ****** * * * = 0;
* *** ** * *** ***
* ** * ** * *** * * ***** (B[i] != '\0')
* * *** * * * *
** * ** * *** **** ** *** ** ** * * * ****** *
* * ** * * **** ****** * ** * **** * *
** ** * * ** ** *****
    
**** *** * **** *** * *** (i = 0; i < 26; i++)
* * * *** * **** **
*** * ** * * * *** * * * *** * (Array1[i] != Array2[i])
* * ** ** * * * * * ** * * * ** *** ** * * ** * *** ** * * ** ** 0;
** * ** **** ** ** * **
*** * * **** ** * **
* ** *** * ** * ** * ** 1;
}

int main()
{
*** * * * ** * **** * A[100],B[100];

**** * ** * * ** ** * * * ** * **
* *** *** *** ** * *** * * * **
** * *** ** ** * ***
** * *** * ****** ** (is_anagrams(A,B))
* * * ** *** ***
*** * * ** * * * * * * * * **** * ** *** ** *** *** * * words or phrases are anagrams");
* * * ** * ***** *** **
* ****** ** ***** **** * printf("Two words or phrases are not anagrams");
**** ** ** * **** * **
** * ** **** *** *** 0;
}
answered by (-193 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[])
{
* * * *************** ** lenA = strlen(A),lenB = strlen(B);
** * * ** * ** * *** * ** * != lenB)
*** * ** *** * * * *** ***** * * 0;

* * * * * ****** * * **** i,j,k,a[26] ={0},b[26] = {0};
* * **** * ** **** ** *** = 0 ; i < lenA ; i++)
****** ** * * * * * *** *
* * ****** * * * ***** ** **** * **** *** ** * ** = 0 ; j < 26 ; j++)
*** * * ** * * *** *** *** *** * **** * *
* * ** * ** * * * * ***** * * * ***** * ** ****** * ** ********* ** * *** * == A[i] || 'A'+j == A[i])
*** ** * ** ***** ** * ** * *** * * * ** * *** * **** *** * * **** *** ** *** ** * ** * *
* * * ***** ** * ****** * * * * **** **** **
* * * ***** *** * ** * * *
***** ******** * * ****** * = 0 ; i < lenB ; i++)
*** ** ****** *** ****
* * * **** **** ** * **** * * ** *** *** * ** * = 0 ; j < 26 ; j++)
** * * * * ******* ** * *** ** **** * ** *
** * * * * * * * * ** * ****** ** ** ** * ** ** * ***** * ** **** *** == B[i] || 'A'+j == B[i])
*** ** * * *** ** * *** * ** *** *** *** * * * *** * * * ** * * * ** * * * * ****
** * * * ** * **** **** * ** **** *****
** ** ** *** **** * *
* * * *** * ****** *** *** = 0 ; j < 26 ; j++)
* * * *** **** * * * ***
* ** * * ** ** ** *** * * ** ** * *** ** * != b[j])
*** * *** * ** ** * *** * * **** *** * * * *** * ** * *** * 0;
** ** ***** *** * * *
* *** * *** ** * ** * ** 1;

}

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

* * ***** ****** *** (is_anagrams(A,B)) ** * * words or phrases are anagrams");
*** *** ****** ***** * printf("Two words or phrases are not * ** *

* ** ** * *** * ** 0;
}
1/100 answered by (-255 points)
edited by
0 0
prog.c: In function 'is_anagrams':
prog.c:38:1: error: expected declaration or statement at end of input
 }
 ^
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct 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 like 0 dislike
Hidden content!
#include * * * * **** *
#include ** * **** ***
#include *** ** * ***
int is_anagrams(char A[],char B[])
{
**** * * * * *** * lenA = strlen(A),lenB = strlen(B),i,j,k;
* **** ***** * * * * a = 0,b = 0;
* * ** *** * ** ** * != lenB)
*** * * * **** * *** * * * * ** ** *** ** * 0;
** ** **** ** **** * * * * = 0 ; k < 26 ; k++)
* * **** * ***** **
*** ** **** * ** *** * ** * *** * **** ** * **** * = 0 ; i < lenA ; i++)
* * *** *** * * * ** * *** * **** * * ** * *
**** * * ** * *** * * * ** ** ***** ****** * ** * * *** *** ** * ** == A[i] || 'A'+k == A[i])
* *** ** * * ******** ** * ** **** ** * ** *** * ******* ** ** * ** ***** ** **** ** *
* * *** * * *** ******* **** * ** *
** * * ** * ** *** * * * * * **** **** *** *** * ** = 0 ; i < lenB ; i++)
** ****** *** ** * * *** * ** * *** ** *
* ***** ** ** * * * *** * *** * * * * ** * * * ** ** *** * * * *** ** == B[i] || 'A'+k == B[i])
*** ** **** * * ** ****** ** *** * * * * * * ** *** * * ******* * ** **** * * ** *
* * ** ** * * ******* *** ***** * * * * **
* ** **** ** ** * * * ** * *** *** * ** * != b)
****** * *** *** ** * *** ** ** ** * * * ***** ** ** * ********* ** ** 0;
*** ** * ** ** * **
**** * ** * ** **** ** * ** * ** * **** ** * *** *** * ** ** * * 1;
}

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

* * ** ** * **** * * 0;
}
answered by (-255 points)
0 0
Case 0: Wrong output
Case 1: Correct output
Case 2: Wrong output
Case 3: Correct output
Case 4: Correct output
0 like 0 dislike
Hidden content!
#include **** *
#include *** ** ** *** *
#include * **** * * *
int is_anagrams(char A[],char B[])
{
* ** *** ** ** ** * *** * YOUR CODE HERE*/
** ** ** **** *** i,count[256]={0};
* ** * * * * * ***** *** *** *
***** * ** * * *** * ****
* ** * ** * * * ** **** * * *** **** * **** ****** **** ******* *
** ** ** ** * ** *** ***
** *** **** * * *** ** **** **
**** ** ** * **** *
* * ***** ** * * ** * ** * * * * * * * ** * ** * *** ** ** * ** * *
**** ** * **** *** ** *
/*
** ** ** ** **** * (A[i]!=0 || B[i]!=0){
* * ****** * * ****** ***** * * * ** ** * * * ** * * * *
** * * ******* ** ** ***** ** **** *** * * 0;
* * ** *** * *** *
*/ * ** *** * * * ** * * ** * ** * 0;

*** * * * * * * (i = 0; i <256 ; i++)
** * * * * * *** * * * * * ** * ** * * (count[i] && i!=' '){
**** ** ** **** ** * ** * ** ** * * ** ** *** ** * * * ** ** **** ** * * * * * ** * *******
* * *** **** * * ***** * ** *** * * * ** * ** * *** * * * 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*/

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

*** ** * * * * ** ** = '\0';
  // * *** * ** * = '\0';
* * **** ** ** * ***** i;
* *** **** * *** * * ** ***
** * * * **** ** * ** ***** * * * ****** *** ****** * **** * * ***** *
* * * * * * **** * * ** * * ** * * ** *** * * **** *
** ** ** * * * * ** * ***** **
* * * * ** * * ** * * * * * * **** ** *** * ** ** *** * *** * *** *
*** ** *** ** * * * ***** ****** *********

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

** ** *** * *** 0;
}
answered by (-196 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 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: 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 ****
#include ****** **
#include ****** ** ** *
int ** *** A[],char B[])
{
* ** * *** ** * * * * YOUR CODE HERE*/
***** * * * ** * ** * *
**** ** ***** * * *** *** ** *** ***** * * *
* ** * * * * * * *
* ** * **** * ** * * * **** * * **** * * *
*** *** ** *** * * ** * * * ** *** ** *** ****
** * * ** ** ** ** ** *
** ***** * **** * (A[i] || B[i])
** ** **** * * * * **** ** * 0;

*** * *** * **** * * *** * (i = 0; i < 256; i++)
* * ** * *** ** *** ****** * * * * *** * * *
* ** * ** * * * * * *** * *** ** *** *** * ** * **** * **** ** * * 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 * **
{
* * ****** * **** * ***** *
*** * * ** ** * ****** * * YOUR CODE HERE*/
* * * ** ** ** * ***** * ** *** * * * *
** *** * * ** ** * ** ** * * ****** ***** *

* * ** ** ******* * OF YOUR CODE*/
* *** ** * ** * ** ** ** * words or phrases are *** *
* **** ** * ** ** * *** ***** words or phrases are not ****** * ***

* * ****** * ** 0;
}
answered by (-196 points)
0 0
prog.c: In function 'main':
prog.c:29:16: warning: format '%s' expects argument of type 'char *', but argument 2 has type 'char (*)[100]' [-Wformat=]
     scanf("%100s",&A);
                ^
prog.c:30:16: warning: format '%s' expects argument of type 'char *', but argument 2 has type 'char (*)[100]' [-Wformat=]
     scanf("%100s",&B);
                ^
0 like 0 dislike
Hidden content!
#include * * * ** *
#include ******* * *** **
#include ** ** * **
int **** * * A[],char B[])
{
* ** * * * ** * ** *** ** YOUR CODE HERE*/
* ** *** * ***** * * * * ** * ***
* ** ** * * * * ** ** ** * ******* *
** * ** ** ***** **
** ** ** * * * ****** * ***** **** ** * *** * ** * *
*** * * ** * * *** * * * * *** * * * ****
** *** * ***** * * **
** * **** ** ******* (A[i] || B[i])
* ** ***** ** * *** * ** ** * ** * 0;

* ** * *** ***** * * * ** (i = 0; i < 256; i++)
* ** *** * * **** * ** * * * * * ** * * ** **
**** ** * ** * * * *** * * ** * **** ** * * ** ** * * ** *** ** *** 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 **** *
{
** ** ** ** * * *** * * * ****
* ***** * * *** * YOUR CODE HERE*/
* * * * * * * * ** * * * * ** ****
* * * * ** ** * **** * ** ** ** * ** * *

*** * *** * OF YOUR CODE*/
** * *** * ** * **** ** * * * words or phrases are ** * **
* * * * ** * * ***** * ** * *** words or phrases are not ***** * ***

** ** ** **** 0;
}
answered by (-196 points)
0 0
prog.c: In function 'main':
prog.c:29:13: warning: format '%s' expects argument of type 'char *', but argument 2 has type 'char (*)[100]' [-Wformat=]
     scanf("%s",&A);
             ^
prog.c:30:13: warning: format '%s' expects argument of type 'char *', but argument 2 has type 'char (*)[100]' [-Wformat=]
     scanf("%s",&B);
             ^
Welcome to Peer-Interaction Programming Learning System (PIPLS) LTLab, National DongHwa University
English 中文 Tiếng Việt
IP:172.69.58.37
©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