input unknown number of variables in one line(In C++) -
I want input in the vector of countless numbers in a row. For example 3 1 1 2 here I know from first input that there are 3 numbers. But I do not know how to store 3 numbers in the next line in a vector array. Another example - 4 2 3 2 3 I want this in C ++ (vector).
int n, x; Std :: vector & lt; Integer & gt; V; If (std :: cin>> n) while (n--) if (std :: cin>> x) v.push_back (x); Else std :: runtime_error ("unavailable value"); else std :: runtime_error ("count count");
Comments
Post a Comment