1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Soloha48 [4]
3 years ago
14

Write a function that checks whether two words are anagrams. Two words are anagrams if they contain the same letters. For exampl

e, silent and listen are anagrams. The header of the function is: def isAnagram(s1, s2): (Hint: Obtain two lists for the two strings. Sort the lists and check if two lists are identical.)
Computers and Technology
1 answer:
marysya [2.9K]3 years ago
7 0

<u>C++ program for the checking if 2 strings are anagram :- </u>

#include<bits/stdc++.h>

using namespace std;

void isAnagram(string s1,string s2) //defining function

{

int an1[256]={},an2[256]={};//declare two count arrays of size 256 an1 and an2.

bool test=true;//taking a bool variable test = true for displaying the result..

for(int i=0;s1[i]&s2[i];i++) // iterating over both the strings.

{

an1[s1[i]]++;//increasing the count of the characters as per their ascii values in count array an1.

an2[s2[i]]++;//increasing the count of the characters as per their ascii values in count array an2.

}

for(int i=0;i<256;i++)//iterating over the count arrays..

{

if(an1[i]!=an2[i])//condition for not anagram.

{

cout<<"not an anagram"<<endl;

test=false;//making test false..

break;//coming out of the loop.

}

}

if(test)//if test is true only then printing..

cout<<"is an anagram"<<endl;

}

int main()

{

string s1,s2;//declaring two strings.

cout<<"Enter both the strings"<<endl;

cin>>s1>>s2;//prompting the strings..

if(s1.length()==s2.length()) //checking whether the lengths of string is same or not

isAnagram(s1,s2); //calling function

else

cout<<"not an anagram"<<endl;

return 0;

}

<u>Explanation</u>

A string is said to be an anagram string of other string if it has same characters but in different order or exactly the same.

for example:-  

string 1="silent"  

string 2="listen"

string 2 is an anagram of string 1.

void isAnagram(string s1,string s2) - This is the function having name isAnagram of void return type having parameters s1 and s2.

You might be interested in
Which of the following best describes a balanced reaction
Ghella [55]

Answer:c

Explanation:

just took the test

7 0
1 year ago
Most software packages have functions for generating _____ about columns of data, which include statistical summaries like contr
GrogVix [38]

Answer:

Descriptives is the correct answer of this question.

Explanation:

Some software packages provide data column definitions that include qualitative summaries such as control averages, mean, average, minimum, standard deviation, number of zero values, number of empty records, etc.

  • A  descriptives summary is a sentence that gives someone information or something.
  • Description is the style of narration creation aimed at making a location, an event, a character or a community vivid.

There are 2 types of Descriptives :-

  1. Narrative type.
  2. Argumentative type.

3 0
3 years ago
Use System.DateTime along with System.Console to implement a simple C# program that does the following:_______.
Andre45 [30]

Answer:

5

Explanation:

I did it to and it was right

3 0
3 years ago
Have you searched Buzz Ch.at on playstore​
deff fn [24]

Answer:

Reorder terms.

y=52x−1

Cancel the common factor of 22.Factor 22 out of −2-2.

y−4=5x2+52⋅(2(−1))y-4=5x2+52⋅(2(-1))

Cancel the common factor.

y−4=5x2+52⋅(2⋅−1)y-4=5x2+52⋅(2⋅-1)

Rewrite the expression.

y−4=5x2+5⋅−1y-4=5x2+5⋅-1

Multiply 55 by −1-1.

y−4=5x2−5

3 0
3 years ago
Bunch of points!!!!!!! help pls
alex41 [277]
Most likely B. Photographs.

Hope this helps!

Have a good day!
4 0
3 years ago
Read 2 more answers
Other questions:
  • ________ employees state-of-the-art computer software and hardware to help people work better together.
    15·1 answer
  • Which f the following is not a characteristic of igneous rock
    8·1 answer
  • Which of the following definition below describes a wall opening?
    6·2 answers
  • In class, we discussed static local variables in C. Answereach question below; if necessary, find and consult a reference on the
    10·1 answer
  • The term that describes the connection of all kinds of devices; computers, phones, laptops, appliances, cars, etc. to the intern
    7·1 answer
  • URLs are directions that browsers follow in order to find specific web page files. What is the first part of the URL that is the
    14·1 answer
  • When creating a chart or graph, which should be completed first?
    9·2 answers
  • What is a type of machine-to-human communication?
    14·1 answer
  • Which is said to be ‘computer on a chip’ (a) Micro processors (b) Microcontrollers (c) Both (c) None of the above
    9·1 answer
  • Typically, a DVD has how many times more capacity than a CD?
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!