Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hello, The C++ question is: ------------------------------------------------------------------------------- Write a program that takes as input 2 strings from the user. Then it determines if one string is

Hello,

The C++ question is:

-------------------------------------------------------------------------------

Write a program that takes as input 2 strings from the user. Then it determines if one string is a permutation of the other string.

If the program answers "yes" to the previous question, meaning the two strings are permutations of each other, determine if each string has all unique characters.

---------------------------------------------------------------------------------

I have completed the first part but I am unsure on how to also determine if each string is all unique characters

-------------------------------------------------------------------------------

#include #include

using namespace std;

// Checking if two strings are permutation bool permutationcheck(string in1, string in2) { // Length of both of the strings int n1 = in1.length(); int n2 = in2.length();

if (n1 != n2) return false;

// Sorting std::sort(in1.begin(), in1.end()); std::sort(in2.begin(), in2.end());

// comparing now that they are sorted for (int i = 0; i < n1; i++) if(in1[i] != in2[i]) return false;

return true; }

int main() { string in1; string in2; cout << "Enter two strings: " << endl; cin >> in1 >> in2;

if(permutationcheck(in1, in2)) cout << "Yes" << endl; else cout << "No" << endl;

return 0; } -------------------------------------------------------------------------------------------------

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Essential Data Protection For Estate Agencies In Singapore 2024

Authors: Yang Yen Thaw Yt

1st Edition

B0CQK79WD3, 979-8872095392

More Books

Students also viewed these Databases questions

Question

a neglect of quality in relationship to international competitors;

Answered: 1 week ago