Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdlib.h> // abs
- #include <iomanip>
- #include <iostream>
- using std::setw,
- std::cout, std::endl;
- auto main()
- -> int
- {
- const int n = 4;
- const int w = 1 << n;
- for( int y = 0; y < 2*w - 1; ++y ) {
- const int cw = w - 1;
- cout << setw( abs( cw - y ) ) << "";
- const int cy = cw - abs( cw - y );
- for( int x = 0; x < w + y; ++x ) {
- const int tx = (x < cy? x : x < w? w - 1 - x : x + 1 - w);
- const int ty = (x < cy? cy : x < w? w - 1 - cy : cy);
- const char ch = (tx & ~ty? ' ' : '@');
- cout << setw( 2 ) << ch;
- }
- cout << endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement