ex00: fix: value are good

This commit is contained in:
Camille Chauvet 2023-10-03 15:24:05 +00:00
parent a4838511eb
commit 76f13820ad

View File

@ -170,12 +170,12 @@ static int get_input(const std::string& file_path, const std::map<unsigned int,
if (!check_line(line, reegex, " | ", INPUT, line_parsed)) if (!check_line(line, reegex, " | ", INPUT, line_parsed))
{ {
std::map<unsigned int, float>::const_iterator it = database.upper_bound(line_parsed.first); std::map<unsigned int, float>::const_iterator it = database.upper_bound(line_parsed.first);
if (it->first < line_parsed.first) if (it == database.begin())
std::cout << "Error: bad input => " << utodate(line_parsed.first) << std::endl; std::cout << "Error: bad input => " << utodate(line_parsed.first) << std::endl;
else else
std::cout << utodate(line_parsed.first) std::cout << utodate(line_parsed.first)
<< " => " << line_parsed.second << " => " << line_parsed.second
<< " = " << line_parsed.second * it->second << std::endl; << " = " << line_parsed.second * (--it)->second << std::endl;
} }
} }