/*
             CREATOR: DAn williams
                DATE:
         DESCRIPTION:
            FILENAME: jumble.c
             STARTED: Dec 13 2003
    OPERATING SYSTEM: Linux
1st VERSION FINISHED:



*/


#include <stdio.h>
#include <string.h>
//#include <conio.h>  // for dos
#include <stdlib.h>

//global variables

void jumble(void );

char word[34];


int main(int argc, char** argv)
{
  

  int  pos; 
  char c;  
  int retcode;
  
  retcode = 0;
  pos = 0;
  
  while ((c = fgetc(stdin)) != EOF) { 
     if (c != ' ') {
        word[pos] = c;
        pos++;
     } else {
       word[pos] = '\0';
       jumble();
       pos = 0;
     }
//     printf("\n");
//     fflush(stdin); 
 }
  
  word[pos] = '\0';
  jumble();
  printf("\n");
  return(retcode);
}


//subroutines

void jumble(void ) {
  
  char hold;
  int source, dest;
    
  if (strlen(word) > 3)
    for(source = (strlen(word)-2); source > 0; source-- ) {
    
         dest = ( rand() % (strlen(word)-3) ) + 1;
                               //  srand((unsigned int) time(NULL));
                               // r = (rand() % n);
                               
    //     printf("source %d, dest %d\n", source, dest); 
                               
         hold         = word[dest];
         word[dest]   = word[source];
         word[source] = hold;

    }
    
    printf("%s ", word);
    
    return;
}
