/* @author Morgan Hargrove * @date 01 Feb. 2013 * Course: CSC 2700, Sec. 2 * Instructor: Isaac Traxler * UVA Problem 642 - Word Amalgamation * Not very proud of it, but here's a quick and ugly (but accepted) c++ version (because java had an undying run-time error...) */ #include <iostream> #include <cstdio> #include <algorithm> using namespace std; int main() { string dictionary[105]; //contains at most 100 words + 5 wiggle room string scramble; string eof = "XXXXXX"; //delimiter (or end of file) int dl = 0; //dictionary length counter while(cin >> dictionary[dl] && dictionary[dl] != eof) dl++; sort(dictionary, dictionary+dl); while(cin >> scramble && scramble != eof) { bool printed = false; sort(scramble.begin(), scramble.end()); for(int i = 0; i < dl; i++) { string tmp = dictionary[i]; sort(tmp.begin(), tmp.end()); if(scramble == tmp) { cout << dictionary[i] << endl; printed = true; } } if(!printed) { cout << "NOT A VALID WORD" << endl; } cout << "******" << endl; } return 0; }The statements and opinions included in these pages are those of only. Any statements and opinions included in these pages are not those of Louisiana State University or the LSU Board of Supervisors.
© 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014