jeudi 16 janvier 2020

What the best way to put integers in a 2D vector from a txt in C++ [duplicate]

When I have a text file like this:

180 60 50 10 2 7 8 11 
70 834 59 82 3 34
84 11 22 49 23 53 7 8 9 11 22

what's the fastest way to put all the data in a 2D vector, so that the vector would look like this:

vector<vector<int> > numbers{ {180, 60, 50, 10, 2, 7, 8, 11}, {70, 834, 59, 82, 3, 34}, {84, 11, 22, 49, 23, 53, 7, 8, 9, 11, 22} }

This needs to be as fast as possible, because it will be submitted to a competition. Thanks in advance!👍

P.S I know how to use fopen, ifstream and all of that jazz

Aucun commentaire:

Enregistrer un commentaire