Welcome to Dream.In.Code
Become a C++ Expert!

Join 136,937 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 1,848 people online right now. Registration is fast and FREE... Join Now!




Having trouble setting up for row and column input for Mandelbrot prog

 
Reply to this topicStart new topic

Having trouble setting up for row and column input for Mandelbrot prog

f3arle551
1 Apr, 2008 - 05:50 PM
Post #1

New D.I.C Head
*

Joined: 21 Jan, 2008
Posts: 14


My Contributions
CODE

#include<iostream>
#include<iomanip>
#include<complex>

using std::cout;
using std::cin;
using std::endl;
using std::setw;
using std::complex;


int main()
{
         double lowx, lowy, hix, hiy, x, k, t;
         int row, colmn, m, varout;
         cout << "Please input the upper left x,y coordinate :"
              << endl;

         cin >> hix >> hiy;
         cout << "Please input the bottom right x,y coordinate : "
              << endl;

         cin >> lowx >> lowy;
         cout << "Please insert the number of rows and columns to be output: "
              << endl;

         cin >> row >> colmn;

         m = 1;
         varout = 1;
         k = (lowx - hix) / (outp - 1);
         t = (hiy - lowy) / outp - 1);
        
         while(varout <= outp)
         {

              x = hix;
              while (outp >= m)
              {
                  cout.precision(2);

                  complex<double> cpn1(x, hiy);
                  complex<double> cpn2(x, hiy);

                  double max_iter = 20;
                  double iteration = 0;                                                                                                              

                  while( iteration <= max_iter )                                                                                                    
                  {                                                                                                                                  
                      cpn2 = cpn2 * cpn2 + cpn1;                                                                                                    
                      double mag = abs(cpn2);                                                                                                        

                      if(( mag > 2.0) || ( iteration >= max_iter))                                                                                  
                      {                                                                                                                              
                          cout << setw(3) << iteration;                                                                                              
                          break;                                                                                                                    
                      }                                                                                                                              
                      ++iteration;                                                                                                                  
                  }                                                                                                                                  
                                                                                                                                                    
                  ++m;                                                                                                                              
                  x = x + k;                                                                                                                        
               }                                                                                                                                    
               cout << endl;                                                                                                                        
               m = 1;                                                                                                                                
               ++varout;                                                                                                                            
               hiy = hiy - t;                                                                                                                        
         }
         return 0;                                                                                                                                  
}


Im trying to set this mandelbrot program to it takes seven inputs: 4 points, the number of rows, the number of columns, and the max iterations but im having trouble figuring out how to set the program up so that it takes the user inputs for rows and columns and outputs it right. any tips or help would be greatly appriciated.
User is offlineProfile CardPM
+Quote Post

bodom658
RE: Having Trouble Setting Up For Row And Column Input For Mandelbrot Prog
1 Apr, 2008 - 08:52 PM
Post #2

D.I.C Head
**

Joined: 22 Feb, 2008
Posts: 154



Thanked: 5 times
My Contributions
a few points:

Instead of writing:
cpp

using std::cout;
using std::cin;
using std::endl;
using std::setw;
using std::complex;


Why not just write using namespace std;?

Also, I belive you missed a parentheses, so this line:
t = (hiy - lowy) / outp - 1);
should really read
t = (hiy - lowy) / (outp - 1);

Also, outp is unidentified, at least that is what my compiler told me. This needs to be declared with your variables or if you meant to use the actual function outp, you should make sure you are using the right syntax and header files (a quick google search, something like 'outp C++ Reference' should turn something up.)

Hope this has helped.

~Cheers!
User is offlineProfile CardPM
+Quote Post

Reply to this topicStart new topic
Time is now: 12/3/08 10:46PM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month