k001
k001
:...

April 2032
        1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30

k001 [userpic]
Пмугирнломара

/* 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.

Comments

Вот за это я и не люблю STL. Развращает.