Oppure

Loading
02/05/06 21:14
Yi
Scusate qualcuno saprebbe dirmi dove sbaglio in questo piccolo programma che dovrebbe disegnare l'insieme di mandelbrot

#include <winbgim.h>
#include <conio.h>
#include <cstdlib>
#include <iostream>
#include <windows.h> 
#include<stdlib.h>
#include<math.h>


using namespace std;


void  rivelrisoluzionegraf(int &width,int &height);
void   mandelbord(int rx,int ry);
float vx1,vx2,vy1,vy2;
 
int main(int argc, char *argv[])
{
  int rx,ry;  
vx1= -5;
vx2= 5;
vy1= -4;
vy2= 4;
  rivelrisoluzionegraf(rx,ry);
   mandelbord(rx,ry);
   
   
    system("PAUSE");
    return EXIT_SUCCESS;
}






void  rivelrisoluzionegraf(int &width,int &height)
    {
        
tagRECT r;
    HWND hWindow;
	long ret;
	

	hWindow = GetDesktopWindow ();
  
	ret = GetWindowRect(hWindow, &r);

	width = r.right;
	height = r.bottom;

}





void mandelbord(int rx,int ry)
 {
    int px,py;
    int itera,numIt;
    int col;
   
    float Zrel,Zim,Crel,Cim,modZ;
    float x,y,pxx,pyy,rx1,ry1;
    px=0;
    py=0;
    
   initwindow(rx,ry); //open  graphics window
 while(!kbhit())
 {   
      
   
     
     while(py<ry)
     {
         while(px<rx)
            {
               rx1=rx;
               ry1=ry; 
               pxx=px;
               pyy=py;     
               pxx= (pxx/rx1);
               pyy=(pyy/ry1);    
               x=vx1+((pxx)*(vx2-vx1)); 
               y=vy1+((pyy)*(vy2-vy1));
                
               Crel=x;
               Cim=y;
               Zrel=0;
               Zim=0;
               itera=0;
                numIt=60;
               modZ=0;
                
                    while((modZ<4)&&(itera<numIt))            
                        {
                            Zrel=(((Zrel*Zrel)-(Zim*Zim))+Crel);
                        
                            Zim= ((2*Zrel*Zim)+Cim);
                        
                          modZ= ((Zrel*Zrel)+(Zim*Zim)); 
                          
                            itera++;
                         }  
                                                          
                
               modZ= ((Zrel*Zrel)+(Zim*Zim)); 
             col=COLOR(255,(255-itera),(255-itera));
             
              if(modZ>4) 
                    {
                    putpixel(px,py,col);
                    }
            
              px++;
            }
           px=0;
           py++;
     }          
     
  while(!kbhit())
  {
}                 
    

      
cleardevice();  
}

      //wait for user to press a key
      closegraph();       //close graphics window

}





Ultima modifica effettuata da pierotofy 01/12/07 22:42
aaa
04/05/06 17:00
Thief
Ke compilatore usi? Perkè ho notato ke hai scritto "#include <cstdlib>", mentre con il borland si usa: "#include <stdlib>" e il sorgente può cambiare in base al compilatore.
aaa
04/05/06 17:30
Yi
Dev-C++ 4.9.9.2 Bloodshed
aaa
01/12/07 4:07
Yin
ni ye xue C++ me????? 8-|8-|
aaa