利用C++中的 stringstream 指定字符分割字符串
class Solution { public: int countSegments(string s) { int cnt = 0; stringstream ss(s); string word; while(ss >> word){ cnt++; } return cnt; } };
京公网安备 11010502049817号