#include #include using namespace std; /* Flag of USA. Download, compile, and run it like this: cd wget https://markmeretzky.com/fordham/1600/src/if/usa.C compile usa.C usa | /usr/bin/pnmtopng > public_html/usa.png Then point your web browser at https://storm.cis.fordham.edu/~jsmith/usa.png */ int main() { const int stripeHeight {10}; //height of each stripe in pixels const int nrows {13 * stripeHeight}; //height of entire flag in pixels const int ncols {nrows * 19 / 10}; //width of entire flag in 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 < 7 * stripeHeight && col < ncols * 2 / 5) { cout << "10 49 97\n"; //blue union jack } else if (row % (2 * stripeHeight) < stripeHeight) { cout << "99 25 66\n"; //red stripe } else { cout << "255 255 255\n"; //white stripe } } } return EXIT_SUCCESS; }