首页 > 其他 > 详细

Mandelbrot图像

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

 

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图像

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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!