码迷,mamicode.com
首页 > 其他好文 > 详细

Mandelbrot图像

时间:2014-05-23 04:08:51      阅读:427      评论:0      收藏:0      [点我收藏+]

标签:class   blog   c   ext   http   a   

 

bubuko.com,布布扣

 bubuko.com,布布扣

 

 

 

 using System;
using System.Collections.Generic;
using System.Text;

namespace ConsoleApplication3
{
    class Program
    {
        static void Main(string[] args)
        {
            double realcoord, imagcoord;
            double realtemp, imagtemp, realtemp2, arg;
            int iterations;
            for (imagcoord = 1.2; imagcoord >= -1.2; imagcoord -= 0.05)
            {
                for (realcoord = -0.6; realcoord <= 1.77; realcoord += 0.03)
                {
                    iterations = 0;
                    realtemp = realcoord;
                    imagtemp = imagcoord;
                    arg = (realcoord * realcoord) + (imagcoord * imagcoord);
                    while ((arg < 4) && (iterations < 40))
                    {
                        realtemp2 = (realtemp * realtemp) - (imagtemp * imagtemp) - realcoord;
                        imagtemp = (2 * realtemp * imagtemp) - imagcoord;
                        realtemp = realtemp2;
                        arg = (imagtemp * imagtemp) + (realtemp * realtemp);
                        iterations += 1;
                    }
                    switch (iterations % 4)
                    {
                        case 0:
                            Console.Write(".");
                            break;
                        case 1:
                            Console.Write("o");
                            break;
                        case 2:
                            Console.Write("O");
                            break;
                        case 3:
                            Console.Write("@");
                            break;
                    }
                }
                Console.Write("\n");
            }
            Console.ReadKey();

         }
    }
}

Mandelbrot图像,布布扣,bubuko.com

Mandelbrot图像

标签:class   blog   c   ext   http   a   

原文地址:http://www.cnblogs.com/zzkgis/p/3742586.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!