#include <iostream>
#include <fstream>
#include <vector>
#include <sstream>
#include <string>
const std::vector<std::vector<double>> read_file(std::ifstream &in)
{
std::vector<std::vector<double>> ret;
std::string line;
std::getline(in, line);
while(1) {
std::stringstream ss;
if(!std::getline(in, line)) break;
ss << line;
double d;
ret.push_back(std::vector<double>());
while(ss >> d) {
ret.rbegin()->push_back(d);
}
}
return ret;
}
std::ostream &operator<<(std::ostream &os, std::vector<std::vector<double>> rhs)
{
for(const auto y: rhs) {
for(const auto x: y) {
os << x << " ";
}
os << std::endl;
}
return os;
}
int main(void)
{
std::ifstream in("result.dat");
std::vector<std::vector<double>> data = read_file(in);
std::cout << data << std::endl;
return 0;
}
|