# Include <iostream>
# Include <string>
# Include <vector>
Using namespace: STD;
Int main ()
{
String S1 ("* We were her pride of 10 she named us :*;");
String S2 ("* Benjamin, Phoenix, the prodigal *");
String S3 ("and perspicacious Pacific Suzanne *;");
String S = S1 + "" + S2 + "" + S3;
String F (",*:;");
String: size_type BPOs = 0;
String: size_type EPOS = 0;
Int num = 0;
Int Len = 0;
Int maxlen = 0;
Int minlen = 0;
Vector <string> maxstring, minstring;
Cout <"The sentense need to process is" <Endl;
Cout <S <Endl;
While (BPOs = S. find_first_not_of (F, BPOs ))! = String: NPOs)
{
++ Num;
EPOS = S. find_first_of (F, BPOs );
If (EPOs = string: NPOs)
Len = S. Size ()-BPOs;
Else
Len = EPOS-BPOs;
Cout <"processing the word" <S. substr (BPOs, Len) <Endl;
If (LEN> maxlen)
{
Maxstring. Clear ();
Maxstring. push_back (S. substr (BPOs, Len ));
Maxlen = Len;
}
Else if (LEN = maxlen)
Maxstring. push_back (S. substr (BPOs, Len ));
If (num = 1)
{
Minlen = Len;
Minstring. push_back (S. substr (BPOs, minlen ));
}
Else {
If (LEN <minlen)
{
Minlen = Len;
Minstring. Clear ();
Minstring. push_back (S. substr (BPOs, minlen ));
}
Else if (LEN = minlen)
Minstring. push_back (S. substr (BPOs, Len ));
}
BPOs = EPOS;
}
Cout <"there is" <num <"Words in the sentense." <Endl;
Cout <"the longest word:" <Endl;
For (vector <string >:: size_type IX = 0; ix! = Maxstring. Size (); ix ++)
Cout <maxstring [ix] <Endl;
Cout <"The smllest word:" <Endl;
For (vector <string >:: size_type IX = 0; ix! = Minstring. Size (); ix ++)
Cout <minstring [ix] <Endl;
System ("pause ");
Return 0;
}