码迷,mamicode.com
首页 > Windows程序 > 详细

C#---Mandelbrot---ShinePans

时间:2015-01-25 22:38:33      阅读:330      评论:0      收藏:0      [点我收藏+]

标签:

技术分享

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Mandelbrot
{
    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 = (realTemp * realTemp) + (imagTemp * imagTemp);
                        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();
        }
    }
}



C#---Mandelbrot---ShinePans

标签:

原文地址:http://blog.csdn.net/shinepan/article/details/43119727

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