c++输入空格分割的数组

vector<int>data;
int tmp;
while(cin>>tmp){
    data.push_back(tmp);
    if(cin.get() == '\n') break;
}

输入

34,2,3,6

输出
34 2 3 6

猜你喜欢

转载自blog.csdn.net/qq_24624539/article/details/108504251