0% found this document useful (0 votes)
9 views2 pages

assignment5.cpp

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views2 pages

assignment5.cpp

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

File: /home/gescoe/SE-B(52)/assignment5.

cpp Page 1 of 2

//kartik Sunil Somvanshi


//SE B-52

#include<iostream>
#include<graphics.h>
using namespace std;

void move(int j,int h,int &x,int &y)


{
if(j==1)
y-=h;
else if(j==2)
x+=h;
else if(j==3)
y+=h;
else if(j==4)
x-=h;

lineto(x,y);
}
void hilbert(int u,int r,int d,int l,int i,int h,int &x,int &y)
{
if(i>0)
{
i--;
hilbert(r,u,l,d,i,h,x,y);
move(u,h,x,y);
delay(100);

hilbert(u,r,d,l,i,h,x,y);
move(r,h,x,y);
delay(100);

hilbert(u,r,d,l,i,h,x,y);
move(d,h,x,y);
delay(100);

hilbert(l,d,r,u,i,h,x,y);
delay(100);

}
}
int main()
{
int n,x=100,y=350,h=30,r=2,d=3,l=4,u=1;
int driver=DETECT,mode=0;
initgraph(&driver,&mode,NULL);

cout<<"Give the value of n:";


cin>>n;

moveto(x,y);
hilbert(u,r,d,l,n,h,x,y);

delay(1000);
closegraph();

return 0;
}
File: /home/gescoe/SE-B(52)/assignment5.cpp Page 2 of 2

You might also like