#include #include #include //for the sqrt function using namespace std; /* Flag of Japan. Download, compile, and run it like this: cd wget https://markmeretzky.com/fordham/1600/src/if/japan.C compile japan japan | /usr/bin/pnmtopng > public_html/japan.png Then point your web browser at https://storm.cis.fordham.edu/~jsmith/japan.png */ int main() { const int miny {-10}; //row number of bottom row const int maxy { 10}; //row number of top row const int minx {-15}; //column number of leftmost column const int maxx { 15}; //column number of 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 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; }