#include #include using namespace std; //colors is an array containing 4 smaller arrays. //(Each of those smaller arrays contains 3 ints.) //In other words, colors is an "array of arrays". //Note that the variable color is in the range 0 to 3 inclusive. //It tells you what row of the array to use. int main() { int nrows {500}; //number of rows of pixels int ncols {nrows * 7 / 5}; //number of columns of pixels cout <<"P3\n" << ncols << " " << nrows << "\n" << 255 << "\n"; int colors[][3] { //red gre blu {255, 239, 213}, //papayawhip {225, 218, 185}, //peachpuff {255, 192, 203}, //pink {240, 128, 128} //lightcoral }; int ncolors {size(colors)}; //the number of colors for (int row {0}; row < nrows; ++row) { for (int col {0}; col < ncols; ++col) { int color {ncolors * col / ncols}; //the current color cout << colors[color][0] << " " //how much red << colors[color][1] << " " //how much green << colors[color][2] << "\n"; //how much blue } } return EXIT_SUCCESS; }