#pragma warning(disable : 4786) #include #include #include using namespace std; void main() { const string str1 = "Please write down the numbers 1--10 in English:"; const string str2 = "one, two, three,four,five,six,seven"; const string str3 = "and eight,nine,ten"; const string sentence = str1 + ' ' + str2 + ' ' + str3; const char *p = sentence.data(); vector< string > vect, vMin, vMax; string str = ""; unsigned int i; for(i = 0; i <= strlen(p); i++) { if(isalpha(p[i])) { str += p[i]; } else if(!str.empty()) { vect.push_back(str); str = ""; } } if(!vect.size()) { cout<<"找不到单词!"< vect[i].length()) { vMin.clear(); vMin.push_back(vect[i]); } else if(vMin[0].length() == vect[i].length()) { vMin.push_back(vect[i]); } if(vMax[0].length() < vect[i].length()) { vMax.clear(); vMax.push_back(vect[i]); } else if(vMax[0].length() == vect[i].length()) { vMax.push_back(vect[i]); } } cout<<"原字符串:"<