ringa_lee
#include <sstream> #include <string> #include <vector> std::string line, num; std::vector<std::vector<int>> v; size_t linenum = 0; while (getline(cin, line)) { std::istringstream iss(line); while (line >> num) { v.push_back(vector<int>()); v[linenum].push_back(stoi(num)); } ++linenum; }
I just finished reading C++ primer, and this is probably the approach.
You are doing a question on OJ. If it is OJ, the required input is actually different from what you understand. You can refer to this
http://blog.csdn.net/sxheliji...
I just finished reading C++ primer, and this is probably the approach.
You are doing a question on OJ. If it is OJ, the required input is actually different from what you understand. You can refer to this
http://blog.csdn.net/sxheliji...