0% found this document useful (0 votes)
4 views1 page

Curve 5

Curve

Uploaded by

jarvisparker3000
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)
4 views1 page

Curve 5

Curve

Uploaded by

jarvisparker3000
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/ 1

1 #include<iostream>

2 #include<graphics.h>
3 using namespace std;
4 void move(int, int, int &,int &);
5 void hilbert(int,int,int,int,int,int,int &,int &);
6 void move(int j,int h,int &x,int &y)
7 {
8 if(j==1)
9 y-=h;
10 else if(j==2)
11 x+=h;
12 else if(j==3)
13 y+=h;
14 else if(j==4)
15 x-=h;
16 lineto(x,y);
17 }
18 void hilbert(int r,int d,int l,int u,int i,int h,int &x,int &y)
19 {
20 if(i>0)
21 {
22 i--;
23 hilbert(d,r,u,l,i,h,x,y);
24 move(r,h,x,y);hilbert(r,d,l,u,i,h,x,y);
25 move(d,h,x,y);
26 hilbert(r,d,l,u,i,h,x,y);
27 move(l,h,x,y);
28 hilbert(u,l,d,r,i,h,x,y);
29 }
30 }
31 int main()
32 {
33 int gd=DETECT,gm;
34 char ch;
35 initgraph(&gd,&gm,NULL);
36 do
37 {
38 int n,x1,y1;
39 int x0=150,y0=100,x,y,h=10,r=2,d=3,l=4,u=1;
40 cout<<"\n Enter the order of the curve: ";
41 cin>>n;
42 x=x0;
43 y=y0;
44 moveto(x,y);
45 hilbert(r,d,l,u,n,h,x,y);
46 cout<<"Do you want to continue(y/n)";
47 cin>>ch;
48 }while(ch=='y');
49 getch();
50 }
51

You might also like