Пмугирнломара
/* This little proggy is here to help check the following statement: * * Aoccdrnig to a rscheearch at an Elingsh uinervtisy, it deosn’t mttaer * in waht oredr the ltteers in a wrod are, the olny iprmoetnt tihng is * taht frist and lsat ltteer is at the rghit pclae. * * Copyright (C) 2003 Kir Kolyshkin <kir@sacred.ru> * Licensed under GNU GPL v.2. */
#include <string> #include <algorithm> #include <sys/time.h> #include <iostream> #include <cctype> #include <clocale> string & reword(string &word) { string::iterator it; if (word.size() > 3) { it = word.end() - 1; while (!isalnum(*it)) it--; random_shuffle (word.begin() + 1 , it); } return word; } int main(int argc, char ** argv) { string word; setlocale(LC_ALL, “”); /* libstdc++ can either use rand() or rand48(), so init both */ srand(time(NULL)); srand48(time(NULL)); while (!cin.eof()) { cin >> word; cout << reword(word) << ‘ ’; } return 0; }
Known bugs: prints last word twice. Yes, I do not know iostream.