Advertisement
alfps

Sierpinsky triangle via bitlevel operations

Apr 4th, 2021
844
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.42 KB | None | 0 0
  1. #include <kickstart/all.hpp>        // https://github.com/alf-p-steinbach/kickstart
  2. using namespace kickstart::all;     // math::intpow, spaces, out, endl
  3.  
  4. auto main() -> int
  5. {
  6.     constexpr int n = math::intpow( 2, 5 );
  7.     for( int y = 0; y < n; ++y ) {
  8.         out << spaces( n - y );
  9.         for( int x = 0; x <= y; ++x ) {
  10.             out << (x & ~y? ' ' : 'o') << ' ';
  11.         }
  12.         out << endl;
  13.     }
  14. }
  15.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement