I'm working on a program to combine two strings based on the ASCII order of the alphabet and also remove all duplicate letters. So far I have
#include <iostream>
using namespace std;
int main() {
string s1, s2;
string combined;
while (true) {
cin >> s1 >> s2;
if (s1 == "quit" && s2 == "quit") break;
cout << "Read " << "\"" << s1 << "\"" << " and " << "\"" << s2 << "\" -> ";
combined = s1+s2;
cout << combined << endl;
}
cout << "Bye";
return 0;
}
the output is supposed to look like Read "binarytriangle" and "ANSIStandard" -> "AINSabdegilnrty"
but I can't seem to figure out how to actually combine them based on the order of the alphabet and remove the duplicate letters. Online I only found how to get the numerical value of a char
based on the ASCII order and not ordering the two strings. I'm thinking of using a for loop, but I'm not sure what I should put inside the parenthesis.