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 <stdio.h>
#include <string.h>
#include <ctype.h>
int is_anagrams(char A[], char B[])
{
** * * **** ** * *** first[26] = {0}, second[26] = {0}, i = 0;
* ******** * ***
 //string 1
* *** ** ** ** **** *** * * ** (A[i] != '\0')
* * ***** ** * ** *
******* * *** ****** * * * * *** * * * * ** * **
** * ** ** * * * * * * ** * * ** ***
* ***** ** * * * ** * **
* * * ** ****
* * ** *** ** *** ** = 0;
* ***** * * *** * *** * *** 2
*** ** * * ** * (B[i] != '\0')
* * * ***** ** *** * **
* * **** * ** * * ** * *** * * ** * * ***
******* ** ** * ** * * ** *** *** ** **** * *
** * *** **** ** * **
* * * **** ** * *
****** * * ** * * * * *
* ** * * ** *** * * * ** (i = 0; i < 26; i++)
* * ** **** * * *
* * ** ****** ** * * ** ** * * ***** * * * * (first[i] != second[i])
** * * * ** ** *** **** * * * * ***** ****** *** ** * * *** * * 0;
*** *** * * ** * **
* * ** * * * ******
*** ****** ** * **** * *** 1;
}
int main(void)
{
** * ** ****** * * * A[100],B[100];
** * * * * * *** **
** * * *** ** * * * *** *** **** *** ** A);
* * * ** **** *** * *** ** ****** B);
* * * * * *** *
** ******* * *** ** ** ** (is_anagrams(A,B))
**** ** * * * * * * ** * words or phrases are anagrams");
** **** **** ** ** ** ** *
** *** * * *** *** **** *** * * * * **** ****** words or phrases are not anagrams");
** ** *** ** * *** * **
* * *** * ** *** * *** * **
}
answered by (323 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[])
{
* ** ** * * ******* * * temp;
* ** *** * * * i, j;
** ** *** * ** n  = strlen(A);
* * **** * ** ** *** n1 = strlen(B);
**** **** * * * ** ** * **
**** * * ******** * * ** n != n1) {
*** ** ****** ** ****** ****** * **** * ** * ** *** *** 0;
*** *** ** *** ** **
**** ** ** ******** ** sort
* * * * * * ** **** * (i = 0; i < n-1; i++) {
* *** ***** * *** ** * ** * *** * ** ** (j = i+1; j < n; j++) {
* * ** ** ** * * *** ** **** *** **** ** * ** ** * * ** * (A[i] > A[j]) {
* ****** ** * * ** * ** * ** * * * *** ** ** ** * ** ** ***** ** * *** * ** ***  = A[i];
* * ** * ** * * *** * *** *** * *** *** ** * * * * ** ** * *** **** * ** * * ***** * ** = A[j];
*** ** * *** * ** * ** * ** * ** * * ** *** * * * ******* * ** * *** * = temp;
* *** * ******* * * ** * * * * * * * ** * * * * *** * * * ** * *** * * ***
** * ** * **** * ** ** *** * ***** * * **** *** ** **** * (B[i] > B[j]) {
******* * * ** ** * * * * ** *** * * ** * * ** ** * * ** * ** ** *  = B[i];
* * ** *** ** *** ** *** * ** ** * ******* * ***** * ** * * * * * ** ** * * ** * * * * = B[j];
** * * ****** * ** * ******** * *** **** * ** * ***** ** **** * *** * * * ** * ** *** = temp;
}
 }
  }
*** * * * ** * ** ** * **** Compare
** **** **** * ** ** = 0; i<n; i++) {
*** ** ** *** ** * * ** ** ** * ** ** * ** != B[i]) {
** * *** ** *** ** **** * ** *** ** * * *** * ** * ** * * ****** **** * * 0;
*** ** * * *** ***** **** * * * * * * *
** ** * * * * ** * * *
  return 1;
}
int main(void)
{
* *** * **** *** * * * A[100],B[100];
* ** * ** ** ****** ***
* **** * * *** * * * * ** *** A);
* * ** * * * **** * * * ** **** * B);
** * **** * **
* ** * ***** ** * ** (is_anagrams(A,B))
** * **** * ** ****** * * *** *** words or phrases are anagrams");
* ** ** * ***** * **
* * ** * ** ** *** **** * * *** ** * **** * ****** *** * words or phrases are not anagrams");
* ** * *** * * ***
* *** * * ** *** **** ***** **
}
answered by (323 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 *** * *** ***
#include <ctype.h>
int is_anagrams(char A[],char B[])
{
*** **** ** ** **** temp;
* * * * * * **** * * * i, j;
* * ** *** ***** * n  = strlen(A);
** ** ** * ** ** * * n1 = strlen(B);
**** * ** ** * * * ** **
* ** *** * * **** n != n1) {
* * *** **** * * *** * * * * * * ** **** 0;
* ** * *** *** ** *
* * * **** * * ** * * * ** sort
* *** **** *** **** ** (i = 0; i < n-1; i++) {
** * * * ********** * * * * * ***** * * ** (j = i+1; j < n; j++) {
** ** * * * **** ** * * *** ** * * ** * * *** ** * ** ** * (A[i] > A[j]) {
**** ** **** * * ** * ***** **** ****** * * ** **** * * * * ** * **** * *** * ******  = A[i];
* *** **** * ** * * ***** ** ** * * * * ** * * *** *** * * ** * ** * ** *** * * = A[j];
* * ** * * * * ****** * * ** **** *** ******* **** ***** * ** **** * ** * ** = temp;
* ** * * ** ****** * **** **** * ** * **** *** * **** * * * * ***** **
* *** * * * * * * * *** *** * ****** * * * * * ** *** * * * ** (B[i] > B[j]) {
** * * *** ** ***** * ** ***** **** * ** ** * * * * ** * * ** * ** * * **** **  = B[i];
**** * * *** ** **** *** **** * ** *** * * * *** * * *** * *** ** ** ** * ** *** = B[j];
****** * * * * ***** ** ** * *** *** *** * *** **** *** * * *** * * ** = temp;
}
 }
  }
** * * * * ** ** ****** Compare
* **** ** ** **** ** * ** = 0; i<n; i++) {
* * ********** * *** * * * ** ** ** ***** != B[i]) {
* * * * * **** * * *** * * * * ** * **** *** * *** ** ** 0;
*** **** * ** * * *** ** ***** *** *
* ** ***** ** * * **
** * * *** 1;
}
int main(void)
{
** ** ** ** * * * * A[100],B[100];
** ** * * ** * * * ** *
** * * * * **** * * ** * * ** *** A);
*** * ** ****** * * * *** ** ** ** * * B);
* * * ** * * *
*** ** * ** ** * ** * ** (is_anagrams(A,B)) printf("Two words or phrases are anagrams\n");
* **** **** ** ** *** printf("Two words or phrases are not anagrams\n");
***** *** * * ** **** * * *
* **** * ** ******** * ** * * 0;
}
answered by (323 points)
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
Case 3: Wrong output
Case 4: Wrong output
0 like 0 dislike
Hidden content!
#include <stdio.h>
#include **** * ** *
#include <ctype.h>
int is_anagrams(char A[],char B[])
{
* ** *** ***** ** ** ** temp;
* *** * *** *** * * * i, j;
** * ** *** *** **** **** n  = strlen(A);
* * * **** *** ** n1 = strlen(B);
** **** ** ** * ******
* ** *** ** * ** ** *** n != n1) {
* * * ** * **** ** **** * * * ***** * * * 0;
** ** * ** ** *
* * ** * ** ** * ** sort
* ** * * *** * * ** (i = 0; i < n-1; i++) {
** **** * * * **** * ***** ** * * * * * ** (j = i+1; j < n; j++) {
* * * ** * ** *** ** ** * * *** * * ** ** *** * *** ** ** * *** * **** (A[i] > A[j]) {
* * * * ** * * ***** * *** **** **** *** *** * ****** * * * ******* * ** * * * * *** *  = A[i];
** *** **** ** ** * *** ***** * *** * **** ** *** * * * *** * ****** *** * ** ** ** * = A[j];
*** *** *** * **** **** *** * **** * ** * *** *** * ** **** *** * * * * ** * * ** ** ***** * ** = temp;
**** * * *** * * ** * ** ** ** ** ** ** * * **** * *** * * **** ** * ***
* ** **** ** * * ***** * * ** **** * ** *** * * * *** * (B[i] > B[j]) {
* * * ***** *** * * ** ** * ** * * * * *** * * * ** ** ** * *** ***** * **  = B[i];
** ** * *** * ** ** * * **** ** ** * * *** ** * * *** ** * * * **** * ** * = B[j];
* * * ** * * * ** * * ***** * ******* **** *** ** *** * * * * * * *** * * ** ** ** = temp;
}
 }
  }
* **** *** *** * * ** Compare
* * *** * * * * ***** * * *** = 0; i<n; i++) {
* * * ** * ** ** * ***** ****** ** ** *** * * * != B[i]) {
*** * *** **** * *** ** *** ** ** *** **** ** * **** * *** * * * ** **** 0;
* * * ** ** ** *** * **** * ** ** * ** **
* * ******* ****** * ** * *
* ** * * 1;
}
int main(void)
{
** ** ** * ** *** *** ******* A[100],B[100];
**** ** * ****
********* * ******* * * ** * * ** *** A);
***** ** * * * *** * **** * * ** B);
* ** * ** * * *
* * * * ** * * * ** * (is_anagrams(A,B)) printf("Two words or phrases are anagrams");
* * * ***** * ** * * * ****** printf("Two words or phrases are not anagrams");
* ** * * ** * **
** ******** * ***** * * 0;
}
answered by (323 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[])
{
* ** * *** * * * * * * * * ***
** ** ** * * * ***** * * YOUR CODE HERE*/
** ** * * * ******** * * ** * ** * **
** * ** ** ** * **
* * ** ** * **** ** ** *** * * ** * * *** ********
* * * *** * ** * * **** * ***** ** **** * ***
* * * *** *** ***** ** * * * * * ** * ** ** * *
* ** * * * ****** *** *** * * **** * * * * * *** ***** * * ** ** 0;
***** ** * * ** ***** ** ** *** * *
* * * ** *** ** *** **** ** * * * * * * * **** return 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)
{
** * * * ** * ** * * * *
** * ** * **** * YOUR CODE HERE*/
*** * * * * * ** * * **** * * **
* * * ** * ****** *** ***** ** *


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

***** * * * * *** * * 0;
}
answered by (-281 points)
0 0
Case 0: Correct output
Case 1: Wrong output
Case 2: Correct output
Case 3: Correct output
Case 4: Wrong output
0 like 0 dislike
Hidden content!
#include *** *** **
#include ** ** ****
int is_anagrams(char A[],char B[])
{
** * *** ** * * **** * * * ** ** ** first[26] = {0}, second[26] = {0}, c = 0;

*** * ** * * * Calculating frequency of characters in first string

******* ** ** ** (A[c] != '\0')
** * ****** **** ** *
* * *** * *** * *** * ** ** * * *** *** ***** * * * ** *** * **** A[c]<='Z')
* * * ** ******* ***** **** **** *
* * ** * * *** * **** ** * **** * ** * ********** ** ** * * * ** ** + 32;
* ** * * *** ******* ****** ** * ** * **
* ********* ** * * * *** * *** * ** *** *
***** * * ******* * *** * ** *
* ***** ****

* **** * ** ** = 0;

*** * *** * **** *** (B[c] != '\0')
** *** * * *
* ** * ** * * ** * ** ** * ** **** * *** * ** * B[c]<='Z')
* ***** * ****** * * * * * * * **
* ** * * ** ****** *** *** * * *** * * ** * * * * * ***** ** + 32;
* ** * ** ** ** * * ****** **
** **** * * * **** * * * *** * *
* ** ** ** * * * * *** ***
** *** * ***

* *** *** ** **** ** * Comparing frequency of characters

***** ****** ******** (c = 0; c < 26; c++)
* *** *** * ** ** *
** ** * *** ** * ** **** ** (first[c] != second[c])
** * * * * * * * ***** *** ** ** * * *** ** *** * 0;
* *** * *

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

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

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


*** ** * * **** (is_anagrams(A,B)) ***** **** ** words or phrases are * * * * * *
* ** * * ** ** * ** words or phrases are not * ****

* * ****** * **** 0;
}
answered by (-323 points)
edited by
0 0
prog.c:5:4: error: expected identifier or '(' before 'while'
    while (a[c] != '\0')
    ^~~~~
prog.c:11:4: warning: data definition has no type or storage class
    c = 0;
    ^
prog.c:11:4: warning: type defaults to 'int' in declaration of 'c' [-Wimplicit-int]
prog.c:11:4: error: redefinition of 'c'
prog.c:1:43: note: previous definition of 'c' was here
    int first[26] = {0}, second[26] = {0}, c = 0;
                                           ^
prog.c:13:4: error: expected identifier or '(' before 'while'
    while (b[c] != '\0')
    ^~~~~
prog.c:21:4: error: expected identifier or '(' before 'for'
    for (c = 0; c < 26; c++)
    ^~~
prog.c:21:18: error: expected '=', ',', ';', 'asm' or '__attribute__' before '<' token
    for (c = 0; c < 26; c++)
                  ^
prog.c:21:25: error: expected '=', ',', ';', 'asm' or '__attribute__' before '++' token
    for (c = 0; c < 26; c++)
                         ^~
prog.c:27:4: error: expected identifier or '(' before 'return'
    return 1;
    ^~~~~~
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[])
{
* ** * **** * YOUR CODE HERE*/
* * ** * ** * ** * * * i;
** * ***** ** *** n = ** ***

** * * * * * ** * = 0; i *** n; i++)
* * *** ****** *
* **** * * ** **** * * ** *** * * = * ** *
** ** * **** * ** *** *** * **** * * **** * ** **** **
* * *** * ** * *

* * * **** * * * * * = 0; i ** n; i++)
* * ** **
** ****** * * ** * * **** * ** * * * ** = ** ***
* * * ** ***** * * ****** ** * **** * * **
* ** * ** ***** **

* * *** * = 0; i < 26; i++)
** * * *** **
* ***** * * * * * * * *** *** **** ** * **** * **** != b[i])
* * * * * * * *** * ** * * ** * **** * *** **** 0;
* ****** ** *
* * *** * * ** **** ** 1;

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

int * *
{
** * ** * * * ***** * *
* * * * * ** * ** ** YOUR CODE HERE*/
** * ** ** *** ** 100, stdin);
***** **** ** * *** ** * *** * * * 100, stdin);

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

* * ** ** * **** 0;
}
answered by (-127 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 * ** ** ** *
#include * * ** **** *
#include * ** * *
int **** ***** * a[],char b[])
{
* * * ** ** **** * ** first[26] = {0}, * * = {0}, c;
***** *
* *** * * ** **** * * * ** * frequency of * * in first string
** * **** for(c=0; * * ++c)
* * * * * ** * * * ****
* ** ***** ** * ** *** ***** ')
** * **** * * *** {
***** * ** *** * **** * ** * ***** *** * * * * * a[c] * * * *
* *** * ** * * **** ** * * * {
* * * ** * * * *** * *** ** * *** * * * ** * *** *** * * **** ***
***** *** * * *** ******* * * * * }
** ** ** * ** ** * ** *** else
** ** * * ** * * *** *   {
**** *               *********** * ** * **
** * *** * *** * ** * * ** }
**** * ******* * ** * **** * * * *
** ** * *** * * }
** * * ** * }
** * ** *** **
*** * *** for(c=0; ** * ++c)
* * ** * * * * **
* ** * * *** * ** * *** ')
* * * * * {
* ** ** * *** * * * ** * * * *** * * * * *** b[c] * * *
* * **** ** * * * **** * ** * * * {
** * * * * * * **** ** **** ** * * * * *** * **
* * * ** * * * ** ** *** * *** }
** * ** * *** * ****** * * * ** * *** * else
* ** ** * * * ** * ** * * * ** * * {
** * * *** *** *** * * * *** * * ** * * * ****** * * * * * * *
** ** * * **** * *** ** * * }
* * * ** * * * ** * **** * **** * ** * *
* **   * * ** ** }
** * **** }
* * *** * * * ** * Comparing frequency of *
* ** *
* * ** * ** for (c = 0; c < 26; c++)
* *** **** * *
**** * * **** * ** *** * * ** * ** ** **** * (first[c] != ***** *
* *** *** * *** ** * ** ** ** * * *** * * ** * ** * ** * *** 0;
*** *** * * *** ** * * * **
** * *
* **** *** **** * 1;
}

int *** ***
{
** ***** * **** * ****
* * ****** * * **** 100, stdin);
* **** ** * ** ** ** 100, stdin);
**** * * *** *** * *** ** * ** 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: Correct output
Case 3: Correct output
Case 4: Correct output
0 like 0 dislike
Hidden content!
#include *** **** * * * * *
#include **** * ***
#include **** * *
int ****** * a[],char b[])
{
** * * * ** * *** ** first[26] = {0}, **** = {0}, c;
* ** **
*** * **** * ** * * ** * * frequency of ******* * in first string
* **
* * * * * * * *** * * **** ** * * ** * * *** || * * * ** ** *** * * ** || a[c]!=' ')
** *** * * * {
* ** * ***** * * * ** for(c=0; * ** * ++c)
*** * ** * ** ** * **** ** ***** ')
** * *** * *** ** * ** * ** * * {
* ** ** ** * **** * * * ** * * * * * ** * * ** * * * ** *
* * *** ****** * * * **** }
* ** ** *** ** *** * ** }
*** * ** }
*** *
    * *** * ** * ** * ** ** * ** || *** * *** ***** * * * ** || b[c]!=' ')
* ** * ** {
**** * * *** * * * for(c=0; * ++c)
** * ** **** * * {
* *** *** * * * ** * * * *** * * **** * * * ')
* * * * * ** ** **** *** *** * ** {
**** * * * ** * *** ** * * * ** ** ** ** * * ** * **** ** * * * ** ** * *
* ** * * * *** * * *** * ** }
** * ** * ** ***** * * *
* * ** ***** ** * * * }
* * * }
******** ** *
* * * **** * Comparing frequency of * * *
** *
* * *** * * * * *** i;
** * * ** * * *** * * ** *** * *
* * * * * ****
* * * **** *** * ** *** *** * ****** if(c==i || c==i+32)
** * * *** * * * * {
* * * *** * ** ** * * *** * **** * for (c = 0; c < 26; c++)
* * *****   * *** * *** * **** * {
** * *** * * ** * ** ** * * * * * * ** if (first[c] != ** **
** * * *** * **** ***** * * *** * ****** ** * * *** * ***** return 0;
** * ***   * ** ** ** * * ** **** ** *
* * * * * ** * }
* **** * *
******* * ***
* * *
** * *** * * * *** * * 1;
}

int ** * *
{
* ** *** * * * * * *
*** *** * ** * * 100, stdin);
***** * *** *** * ** 100, stdin);
* * * *** * * * * ** * * * **** * words or phrases are * *** * * * * *
* ****** ** *** ***** ** words or phrases are not * * ** ***

* ** **** ** *** * 0;
}
answered by (-249 points)
0 0
Case 0: Correct output
Case 1: Wrong output
Case 2: Correct output
Case 3: Correct output
Case 4: Wrong output
0 like 0 dislike
Hidden content!
#include * * **** * *
#include * * * * **
#include **** * *** **
int * * ** a[],char b[])
{
*** * * * * first[26] = {0}, * * ** = {0}, c;
* *****
****** * ***** *** * * * ** frequency of ** ** ** in first string
*** *
*** ** *** * for(c=0; * ** * * ++c)
*** *** ** * ** *** ** *** * **** ')
* ** * ** * ** * {
* *** ** * * ** ** * **** * ***** * * ** *
** * **** * * * * *** }
* * * * * * * ****** * ***
* * * * }
** * * ** ****
* * **** * for(c=0; * * ++c)
* * * * {
**** * *** *** * * * * ***** ')
* ** * ** * *** * {
** * * ** * * ** ** ** ** * *** ** * * ******** ** ** ** ** ** **
** *** *** **** * ** ** * }
* *** * *** ** *
* * ***** * }
** ** ** * ** frequency of * ** **
* *** *
*** * * *** * * * (c = 0; c < 26; c++)
*** * ** ***
** ** ** *** ** ** ** * * != * *****
** *** ** * * *** ** *********** * ***** ** ** * 0;
* *** *** ** * ** **
*
********** ** * * * 1;
}

int *** **
{
** ** ** *** ** * ** * ** *
* **** ** ** ** * * * 100, stdin);
** * **** ** *** ** ** 100, stdin);
* ** * ** * ****** * * * * **** * ** ** 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
Welcome to Peer-Interaction Programming Learning System (PIPLS) LTLab, National DongHwa University
English 中文 Tiếng Việt
IP:172.70.100.108
©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