#include "color_map.h" #include // country -- the ID of a country we want to color // world -- map object bool MapColor(int country, map& world) { if (country == world.numOfCountries) return true; bool doneColoring = false; bool aColorRemaining = true; color c(red); // color c= red; while (aColorRemaining == true && doneColoring == false) { if (world.isValidColoring(country, c)) { world.colorCountry(country, c); doneColoring = MapColor(country+1, world); if (doneColoring) break; } if (c == color(yellow)) aColorRemaining = false; else ++c; } if (doneColoring == false) // backtracking { world.colorCountry(country, color(none)); } return doneColoring; } int main() { map world; std::ifstream in("map.txt"); in >> world; MapColor(0, world); std::cout << world; std::cout << std::endl; }