C++.



         

- 4


/p>

}

, , , . , . , .

#include <string>

void filter_string( string &str,

string filt_elems = string("\",."))

{

string::size_type pos = 0;

while (( pos = str.find_first_of( filt_elems, pos ))

!= string::npos )

str.erase( pos, 1 );

}

filter_string()

, , :

template <class InputIterator>

void filter_string( InputIterator first, InputIterator last,

string filt_elems = string("\",."))

{

for ( ; first != last; first++ )

{

string::size_type pos = 0;

while (( pos = (*first).find_first_of( filt_elems, pos ))

!= string::npos )

(*first).erase( pos, 1 );

}

}

:

#include <string>

#include <algorithm>

#include <iterator>

#include <vector>

#include <iostream>

bool length_less( string s1, string s2 )

{ return s1.size() < s2.size(); }

int main()

{

istream_iterator< string > input( cin ), eos;

vector< string > text;

// copy -

copy( input, eos, back_inserter( text ));

string filt_elems( "\",.;:");

filter_string( text.begin(), text.end(), filt_elems );

int cnt = text.size();

// max_element -

string *max = max_element( text.begin(), text.end(),

length_less );

int len = max->size();

cout << " "

<< cnt << endl;

cout << " "

<< len << endl;

cout << " "

<< *max << endl;

<