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
9.
Liula [17]

Answer:

128 is ur answer

Explanation:

please mark me as brainilist

5 0
2 years ago
Sending a employee an email with important criticism represents a problem which communication process
Evgen [1.6K]
<span>I am definitely sure that sending an employee an email with important criticism represents a problem in message channel. Message channel is one of the ways through which two parties (manager-employee) communicate with each other.</span>
7 0
3 years ago
During her presentation, Marie wanted more freedom to move about the room and interact with her audience. She can use _____.
S_A_V [24]

Answer:

The correct answer is:

"a laser pointer and a remote control"

Explanation:

Let us look at the options one by one.

notes pages and an LCD projector

When she is using these options, she cannot have the freedom to move as she has to operate the projector somehow.

laptop computer and a pointer

In this case she has to operate laptop so movement will be reduced.

<u>A laser pointer and remote control</u> will give her a lot of freedom to move as she can use the remote control to operate the slides and the pointer to point stuff ont the slides.

Hence,

The correct answer is:

"a laser pointer and a remote control"

5 0
3 years ago
What does getfenv() do?
mariarad [96]

Answer: getfenv() is a type of function. Particually a envirotment function. for a lua coding.

Explanation: What this does it goes thourgh  line of code in a particular order.

This means. getfenv is used to get the current environment of a function. It returns a table of all the things that function has access to. You can also set the environment of a function to another environment.

Forgot to include examples of where this could be used. Although not very common uses, there are some. In the past Script Builders used getfenv to get the environment of a script, and setfenv to set the environment of a created script’s environment to a fake environment, so they couldn’t affect the real one. They could also inject custom global functions.

Not entirely sure if this uses getfenv or setfenv, but the use in Crazyman32’s AeroGameFramework is making the environment of each module have access to other modules without having to require them, and having access to remotes without having to directly reference them.

5 0
2 years ago
Read 2 more answers
Match the item to the type.​
Roman55 [17]
The chart with the circle in the top right is a pie chart

the top left chart on enrollment is a histogram

the bottom chart is a bar chart
3 0
2 years ago
Other questions:
  • In a social networking site your personal information is listed under your inbox. home. status. profile.
    11·1 answer
  • A(n)________________ is something that goes into a system a resource such as time,money,communication,etc
    10·1 answer
  • What symbol following a menu command lets you know that a dialog box will be displayed? an arrow a check mark an ellipse a radio
    5·2 answers
  • You have just driven to the Hewlett-Packard site in Corvallis to field-interview a programmer. You sit down in a conference room
    6·1 answer
  • A device receives a Transmission Control Protocol (TCP) packet. The device understands where the actual data payload begins. Whi
    15·1 answer
  • How many data bits are sent in a single psk31 character?
    15·1 answer
  • Write a function safeOpen() that takes one parameter, filename — a string giving the pathname of the file to be opened for readi
    15·1 answer
  • Running away from home
    11·2 answers
  • 2 differences between system and applications software​
    9·2 answers
  • What is a good theme statement for the short Pixar film "bao"?
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!