C++混合字符输入转整数代码示例 vector<int> f; vector<int> l; string str; int sum=0; cin>>str; for(auto i:str) { if(i==':') { f.push_back(sum); sum = 0; continue; } if(i==',') { l.push_back(sum); sum = 0; continue; } sum = sum*10+atoi(&i); }