緣由https://ask.csdn.net/questions/1010912
void 輸出最長字元串(string a)
{//緣由https://ask.csdn.net/questions/1010912
string b = "", c = "";
int aa = 0, bb = 0, cc = 0;
while (a[aa] != '\n')
if (a[aa] != ' ')b += a[aa++], ++bb, cout << b << "\t" << bb, Sleep(400), system("cls");
else
if (bb>cc)c = b, bb = 0, b = "", ++aa, cout << c, Sleep(400), system("cls");
if (bb>cc)c = b; cout << "最長字元串:" << c << endl;
}
輸出最長字元串("aaa aa aaaa a aaaaa\n");
![](https://img.laitimes.com/img/9ZDMuAjOiMmIsIjOiQnIsIiZpdmLxQzN1ATMwQTMwEjMxkTMwIzLc52YucWbp5GZzNmLn9Gbi1yZtl2Lc9CX6MHc0RHaiojIsJye.gif)