fork download
  1. #include <complex>
  2. #include <iostream>
  3.  
  4. int main() {
  5. double const xmin = -2, xmax = 1, ymin = -1, ymax = 1;
  6. int const cols = 80;
  7. double const inc = ( xmax - xmin ) / cols;
  8.  
  9. double const threshold = 1e6;
  10. long const timeout = std::exp( 6 );
  11.  
  12. char const *colors = " .xOX";
  13.  
  14. for ( double y = ymax; y > ymin; y -= inc ) {
  15. for ( double x = xmin; x < xmax; x += inc ) {
  16. std::complex< double > c0( x, y ), c = c0;
  17. for ( long i = 0; i != timeout; ++ i ) {
  18. c = c * c + c0;
  19. if ( abs( c ) > threshold ) {
  20. std::cout << colors[ int( std::log( i ) ) ];
  21. goto escaped;
  22. }
  23. }
  24. std::cout << '$';
  25. escaped:;
  26. }
  27. std::cout << '\n';
  28. }
  29. }
Success #stdin #stdout 0.03s 2884KB
stdin
Standard input is empty
stdout
                                              .........                         
                                             ......x...                         
                                             .....x.....                        
                                            ......xx....                        
                                           ....x.x$x.....                       
                                         ......xO$$$Oxx...                      
                                       ........x$$$$$x.....                     
                                     ..........x$$$$$O.........                 
                                   .............$$$$$............               
                                   ....x...xx...x$$$x..x.x.....x.               
                                  ...xxxxx.O$X$$$$$$$$$OOX.....O..              
                                 ......O$xx$$$$$$$$$$$$$$xO.Oxxx..              
                               .......x$$x$$$$$$$$$$$$$$$$$X$$x...              
                              .........x$$$$$$$$$$$$$$$$$$$$$$$...              
                         ...........x.X$$$$$$$$$$$$$$$$$$$$$$x....              
                  ..................$$$$$$$$$$$$$$$$$$$$$$$$$$.....             
                  ..................x$$$$$$$$$$$$$$$$$$$$$$$$$$....             
                 .........x.......xxX$$$$$$$$$$$$$$$$$$$$$$$$$$Oxx.             
                 ....x....xx.......x$$$$$$$$$$$$$$$$$$$$$$$$$$$$$x.             
                ......xx..xO.x....XO$$$$$$$$$$$$$$$$$$$$$$$$$$$$...             
               .......x$x$$XO$x...X$$$$$$$$$$$$$$$$$$$$$$$$$$$$$...             
              ........xX$$$$$$$x..X$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$x.             
             .......xx$$$$$$$$$$O.$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$...             
           ..........O$$$$$$$$$$$x$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$x..             
       ...........x.x$$$$$$$$$$$$x$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$...             
    .............xxxO$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$...              
 ...............x$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$....              
 ...............x$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$O....              
   ..............x$$x$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$X...              
      ............x.O$$$$$$$$$$$$O$$$$$$$$$$$$$$$$$$$$$$$$$$$$$....             
          ......x...x$$$$$$$$$$$$x$$$$$$$$$$$$$$$$$$$$$$$$$$$$$X...             
            .........$$$$$$$$$$$Ox$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$...             
              ........x$$$$$$$$$..x$$$$$$$$$$$$$$$$$$$$$$$$$$$$$xx.             
               ......xx$x$$$$Ox...O$$$$$$$$$$$$$$$$$$$$$$$$$$$$$x..             
                ......xO..x$.x....O$$$$$$$$$$$$$$$$$$$$$$$$$$$$$...             
                 ..........x.x.....O$$$$$$$$$$$$$$$$$$$$$$$$$$$OO..             
                 .................xO$$$$$$$$$$$$$$$$$$$$$$$$$$$$$x.             
                  ..................x$$$$$$$$$$$$$$$$$$$$$$$$$$....             
                  ..................O$$$$$$$$$$$$$$$$$$$$$$$$$xx...             
                   ................xxxx$$$$$$$$$$$$$$$$$$$$$$$.....             
                            ..........xx$$$$$$$$$$$$$$$$$$$$$$x...              
                               ........$$$$$$$$$$$$$$$$$$$$x$$$...              
                                ......O$$XO$$$$$$$$$$$$$$$$.x$$...              
                                 ....x.Xx..O$$$$$$$$$$$$O$.....x..              
                                  ....xx...OxOxOOO$XOXxO.x.....x.               
                                   .............$$$$$............               
                                    ...........O$$$$$x..........                
                                      .........x$$$$$x......                    
                                        .......x$$$$$O....                      
                                          ....xO.x$xx....                       
                                           .......$x.....                       
                                            ............                        
                                             ..........                         
                                              ....x.x..