Question: Write a C++ program called all_subsets.cpp which displays all subsets for an input set. In the problem, your program should read n characters from a
Write a C++ program called all_subsets.cpp which displays all subsets for an input set. In the problem, your program should read n characters from a user and display all subsets of the characters. In the program, you can assume that the number of input characters is less than or equal to 15. Your program should ask a user to enter the number of input characters. After that, it should read the characters. For the problem, you should verify that all input characters are distinct.
Use the binary representation from 0 to 2n 1 for the input n. For example, if the number of input characters is 2, all binary numbers from 0 to 22 1 (= 3) will be 00, 01, 10, and 11. Try to find a correspondence between a subset and its binary representation.
=======================================================
$ g++ -o all_subsets all_subsets.cpp
$ ./all_subsets
Number of input characters: 3
Enter 3 characters: a c a
Invalid input set. Duplicated elements.
=======================================================
This is another sample:
$ g++ -o all_subsets all_subsets.cpp
$ ./all_subsets
Number of input characters: 2
Enter 2 characters: a c
===== All Subsets =====
{}
{c}
{a}
{a,c}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
