#include #include #include //for the sqrt function using namespace std; //Flag of Japan. //Run it like this: ./a.out | /usr/bin/pnmtopng > japan.png // file japan.png // cp japan.png public_html int main() { int miny {-10}; //bottom row int maxy { 10}; //top row int minx {-15}; //leftmost column int maxx { 15}; //rightmost column int nrows {maxy - miny + 1}; //number of rows of pixels int ncols {maxx - minx + 1}; //number of columns of pixels double radius {.3 * nrows}; //of red circle cout << "P3\n" << ncols << " " << nrows << "\n" << 255 << "\n"; for (int y {miny}; y <= maxy; ++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; }