zoukankan      html  css  js  c++  java
  • 学习for while switch 循环生成的图

    从书本《C#入门经典第五版》上记录下来的学习for  while switch 循环生成的图。

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    
    namespace ConsoleApplication1
    {
        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("
    ");
                }
    
                Console.ReadKey();
    
            }
    
        }
    }
    

      

  • 相关阅读:
    html 入门 "地表最强"干货 你值得拥有
    python信号量
    死锁 与 递归锁
    互斥锁
    进程之间的通讯
    进程与多道技术
    进程对象常用属性
    开启子进程的方式2
    牛客多校赛2K Keyboard Free
    省选刷题小记 (06~10)
  • 原文地址:https://www.cnblogs.com/lzlcn/p/4215255.html
Copyright © 2011-2022 走看看