Advertisement
Guest User

Untitled

a guest
Apr 20th, 2015
261
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.87 KB | None | 0 0
  1. #include <stdlib.h>
  2.  
  3. #include <string.h>
  4.  
  5. #include <stdio.h>
  6. int escapeSteps (double x0, double y0);
  7.  
  8.  
  9. int main (int argc, char * argv []){
  10.     int row = 0;
  11.     double y = 2;
  12.     while (row <100){
  13.         int col = 0;
  14.         double x = -2;
  15.         while (col < 100){
  16.             if (escapeSteps(x, y) == 255) {
  17.                 printf("*");
  18.             } else {
  19.                 printf(" ");
  20.             }
  21.             col++;
  22.             x += 0.04;
  23.         }
  24.         printf("\n");
  25.         row++;
  26.         y -= 0.04;
  27.     }
  28.     return EXIT_SUCCESS;
  29. }
  30.  
  31. int escapeSteps (double x0, double y0){
  32.     double x = 0.0;
  33.     double y = 0.0;
  34.     double xtemp;
  35.     int iteration = 0;
  36.     while ( x*x + y*y < 2*2  && iteration < 255) {
  37.         xtemp = x*x - y*y + x0;
  38.         y = 2*x*y + y0;
  39.         x = xtemp;
  40.         iteration++;
  41.     }
  42.     return iteration;
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement