8.112345678910111213141516istream& iofunc(istream& is) { string s; while (is >> s) { cout << s << endl; } is.clear(); return is;}int main() { iofunc(cin); system("pause"); return 0;} 8.4123456789101112vector<string>v;ifstream ifs;ifs.open("ifile.txt", ios::in);if (ifs.is_open()) //if(ifs>>s)逐个单词 { string s; while (getline(ifs,s)) { v.push_back(s); cout << s << endl; } ifs.close();} 8.10123456789101112string line, word;vector<string> vec;while (getline(cin,line)){ vec.push_back(line); cout << vec.back() << endl; istringstream record(vec.back()); while (record >> word) { cout << word << endl; }} 8.1112345678910111213141516171819202122232425262728293031struct PersonInfo { string name; vector<string> phones;};int main() { string line, word; vector<PersonInfo> people; istringstream record; while (getline(cin, line)) { record.str(line); PersonInfo info; record >> info.name; while (record >> word) { info.phones.push_back(word); } record.clear();//复位 people.push_back(info); } for (const auto &entry : people) { cout << entry.name << " "; for (const auto &ph : entry.phones) { cout << ph << " "; } cout << endl; } return 0;}