черканите если есть время
Добавлено: 14 апр 2010, 00:34
Дана строка, состоящая из слов, разделенных пробелами (одним или несколькими). Определить длину самого короткого слова.
Код: Выделить всё
#include <iostream>
#include <sstream>
#include <algorithm>
#include <iterator>
bool compare(const std::string& a, const std::string& b) { return a.length() < b.length(); }
int main()
{
std::istringstream iss("asdasd sadfsdfas dfgr sdqw lsdjkflk afd qgew");
std::istream_iterator<std::string> iword(iss);
std::cout << (*std::min_element(iword, std::istream_iterator<std::string>(), compare)).length() << std::endl;
return 0;
}