Test instructions outputs all words in the input word that can be made up of another two words
Application of STL set enumerate all possible splits for each word and see if all two of the broken words exist, you can output the
#include <bits/stdc++.h>using namespace std;string A, b;set<string> s;set<string>::iterator i;int Main () { int l; while (Cin >> a) S.insert (a); for (i = S.begin (); I! = S.end (); ++i) { L = i->length () ; for (int j = 1; j < l-1; ++j) { a = i->substr (0, J); b = I->substr (j); if (S.count (a) && S.count (b)) { cout << (*i) << Endl; Break ; }}} return 0;}
Compound Words
You is to find all the two-word compound words in a dictionary. A two-word compound word is a word in the dictionary that's the concatenation of exactly the other words in the Dictionar Y.
Input
Standard input consists of a number of lowercase words, one per line, in alphabetical order. There'll be is no more than 120,000 words.
Output
Your output should contain all the compound words, one per line, in alphabetical order.
Sample Input
Aalienbornlesslienneverneverthelessnewnewbornthezebra
Sample Output
Aliennewborn
UVa 10391 Compound Words (compound word)