A: Title
Enter a series of words made up of lowercase letters. Enter the sort order according to the dictionary, and no more than 120,000. Find all compound word, just a word that is formed by connecting two words
(A) Sample Input
a alien born less lien never nevertheless new newborn the zebra
(B) Sample Output
alien
newborn
Two: code implementation
#define _CRT_SECURE_NO_WARNINGS #include <iostream> #include <vector> #include <string> using namespace std; int main() { freopen("data5_5_h.in", "r", stdin); freopen("data5_5_h.out", "w", stdout); int pos; string word; vector<string> word_vec; while(cin >> Word) // first access to information word_vec.push_back (Word); for ( int i = 1 ; i <word_vec.size (); i ++) // start testing for ( int J = i - 1 ; J> = 0 ; J,) // check the first part IF ((POS = word_vec [I] .find (word_vec [J])) =! String :: NPoS) for ( int K = 0 ; K <word_vec.size (); K ++) // check latter half { IF (K || K == J == I) Continue; if (word_vec[i].find(word_vec[k], pos + word_vec[j].length()) != string::npos) { if ((pos + word_vec[k].length() + word_vec[j].length()) == word_vec[i].length()) cout << word_vec[i] << endl; } } freopen("CON", "r", stdin); freopen("CON", "w", stdout); return 0; }