Question: zybooks 2 0 . 1 2 Project 4 : Map Coloring 2 0 . 1 2 Project 4 : Map Coloring Testing is complete. Please

zybooks 20.12 Project 4: Map Coloring
20.12 Project 4: Map Coloring
Testing is complete. Please alert me if you encounter problems.
Construct a 4 coloring of a map such that no two neighboring countries have the same color. For this project you will read in a map
encoded as a text file. An example Follows:
AABBBBBCCDDEFGGG HHIHHJJJKK
ABBBBBCCDDEFGGGGHHHIHHJJJKK
AAAAAALLLLLEMMMMMHHHHHHHHHHH
AAAAALLLLEMMMM HHHHHHHHHH
Are not part of any country and do not have to be colored.
Countries will be marked A though Z.
While a 4 coloring of the map might look like:
3311111443341333311131122233
3311111443341333311131122233
3333332222242222211111111111
3333332222242222211111111111
You are asked to produce a string in the following format:
Color 1: B, F, H
Color 2: J, L, M
Color 3: A, D, G, K
Color 4: C, E
The grading engine will parse this string to verify your coloring. Valid colorings are not unique.
You must implement the following function:
std::string colormap(std:string filename)
The input is the name of a file (eg "map.txt") and you return the coloring described above.
The rest of your design is up to you.
main.cpp code
#include
#include
#include
#include "colormap.h"
using namespace std;
int main(){
/* you may modify for testing. */
std::string mapname;
std::cin >> mapname;
std::string mapkey = colormap((mapname+".txt"));
std::cout mapkey;
return 0;
}
Given colormap.h code
#ifndef _colormap_h
#define _colormap_h
#include
#include
#include
std::string colormap(std::string);
#endif
Given colormap.cppcode
#include
#include
#include "colormap.h"
std::string colormap(std::string){
return "TODO";
}
zybooks 2 0 . 1 2 Project 4 : Map Coloring 2 0 .

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!