#include #include #include using namespace std; /* The outer loop goes through all the rows, from top to bottom. The inner loop goes through the pixels of each row, from left to right. */ int main() { const int miny {-30}; //row number of the bottom row const int maxy { 30}; //row number of the top row const int minx {-25}; //column number of the leftmost column const int maxx { 25}; //column number of the rightmost column const int nrows {maxy - miny + 1}; //number of rows of pixels const int ncols {maxx - minx + 1}; //number of columns of pixels const double radius {.3 * nrows}; //of the red circle cout << "P3\n" << ncols << " " << nrows << "\n" << 255 << "\n"; for (int y {maxy}; y >= miny; --y) { for (int x {minx}; x <= maxx; ++x) { if (sqrt(x*x + y*y) <= radius) { cout << "255 0 0\n"; //in the red circle } else { cout << "255 255 255\n"; //in white background } } } return EXIT_SUCCESS; }