#include #include using namespace std; int main() { const int nrows {30}; //number of rows of pixels const int ncols {40}; //number of columns of pixels cout << "P3\n" << ncols << " " << nrows << "\n" << 255 << "\n"; for (int row {0}; row < nrows; ++row) { for (int col {0}; col < ncols; ++col) { if (row < 10) { cout << "0 0 0\n"; //top third is black } else if (row < 20) { cout << "255 0 0\n"; // middle third is red } else { cout << "255 215 0\n"; //lower third is yellow } } } return EXIT_SUCCESS; }