#include #include #include #include #include #include int main() { std::ifstream ifs("data_test.txt"); if(!ifs.is_open()) { std::cerr << "Missing data.txt." << std::endl; return -1; } unsigned long total = 0; unsigned long total_pt2 = 0; std::vector> cals; for(std::string line; std::getline(ifs, line); ) { if(line == "") continue; cals.push_back({}); std::istringstream input(line); // for each value in the line: std::vector nums; for(std::string value; std::getline(input, value, ' '); ) cals.back().push_back(std::atoi(value.c_str())); } for(auto cal : cals) { for(auto num : cal) { std::cout << num << " "; } std::cout << std::endl; } std::cout << " Total: " << total << std::endl; std::cout << "PT2 Total: " << total_pt2 << std::endl; return 0; }