Mandelbrot图像
2024-07-05 12:12:50 228人阅读
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(); } } } |
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉:
投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。