#include <iostream>
#include <string>
void pec (std::string Str)
{
std::string S = Str + " ";
short int Min = S.length();
std::string w;
while (!S.empty())
{
w.append(S, 0, S.find(" "));
if (w.length() < Min)
Min = w.length();
S.erase(0, S.find(" ") + 1);
w.clear();
}
S = Str + " ";
while (!S.empty())
{
w.append(S, 0, S.find(" "));
if (w.length() == Min)
std::cout << w << std::endl;
S.erase(0, S.find(" ") + 1);
w.clear();
}
}
int main()
{
std::string stroka;
std::cout <<"Vvedi srtoku: " <<endl;
std::getline(std::cin, stroka);
std::cout << "Slova s min kol-vom simvolov: " << endl;
pec (stroka);
std::cin.get();
return 0;
} |