Wrox Programmer Forums
|
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 12th, 2006, 04:06 PM
Registered User
 
Join Date: Feb 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default heeelp!!

hi every body. i'm new in c# bout book "beginers c#"
and i get stacked on this code:
namespace Ch04Ex06
{
   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();
      }
   }
}
Can any one explayne to me how dose it works (its a console aplication)??:D
P.S sorry 4 my bad eng.

 
Old February 12th, 2006, 07:06 PM
Wrox Technical Editor
 
Join Date: Dec 2005
Posts: 271
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Your source code is intended to demonstrate for loops and branching via a switch statement.
Your program will display a Mandelbrot set, using plain text characters.

"Each position in a Mandelbrot image corresponds to an imaginary number of the form N = x + y*i, where the real part is x, the imaginary part is y, and i is the square root of -1. The x and y coordinates of the position in the image correspond to the x and y parts of the imaginary number."

Wiki a Madelbrot set: http://en.wikipedia.org/wiki/Mandelbrot_set



- A.Kahtava
 
Old February 12th, 2006, 07:28 PM
Registered User
 
Join Date: Feb 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

thank u thank u thank u!!!!:D







Similar Threads
Thread Thread Starter Forum Replies Last Post
HEEELP!!! - strWhere Problem with DoCmd.OpenReport HenryE Access 1 August 4th, 2004 01:07 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.