sstream

#include

#include

#include

using namespace std;

int main()

{

string line;

while (getline(cin, line))//输入一行存入line 如123 100 200

{

int sum = 0, x;

stringstream ss(line);//stringstream字符串流 ostringstream istringstream

while (ss >> x)

sum += x;

cout << sum << endl;//423

}

}

你可能感兴趣的:(sstream)