
-----------------------------------
jamonathin
Thu May 12, 2005 8:59 am

Word Scrambler
-----------------------------------
This is a program that scrambles up a word (obviously).  It slow though.  The max amount of letters it does in a resonable amount of time is 4  :? .  Here it is, and if anyone knows a faster way, I'm curious to know  :)

-----------------------------------
wtd
Thu May 12, 2005 12:16 pm


-----------------------------------
For one thing, when you're doing a lot of string concatenation (+=), don't.  Instead use a stringstream.

You're using string constants where you just have characters.  Don't.

You're using C-style casts.  Don't.

You're using ints where you want boolean values.  Just use bools.

So, wihout changing too much else logic-wise, let's look at this function.

#include 

int mix (string thing)

{

    int l(thing.length());

    int hold;
    bool taken

That said... learn to use the power of the Standard Template Library.

#include 
#include 
#include 

int main()
{
   std::string input;
   std::cin >> input;
   std::random_shuffle(input.begin(), input.end());
   std::cout 