8.1&&8.2
1 #include <iostream> 2 #include <vector> 3 #include <string> 4 5 using namespace std; 6 7 istream &func(istream &is) 8 { 9 int val; 10 while (is >> val && !is.eof()) { 11 cout << val << endl; 12 } 13 is.clear(); //复位所有错误标志位 14 } 15 16 int main() 17 { 18 func(cin); 19 return 0; 20 }