fork download
  1.  
  2. #include<stdio.h>
  3.  
  4. using namespace std;
  5.  
  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.  
  19. void hilbert(int r, int d, int l, int u, int i, int h, int &x, int &y)
  20. {
  21. if(i>0)
  22. {
  23. i--;
  24. hilbert(d,r,u,l,i,h,x,y);
  25. move(r,h,x,y);
  26. hilbert(r,d,l,u,i,h,x,y);
  27. move(d,h,x,y);
  28. hilbert(r,d,l,u,i,h,x,y);
  29. move(l,h,x,y);
  30. hilbert(u,l,d,r,i,h,x,y);
  31. }
  32. }
  33.  
  34. int main()
  35. {
  36. int n, x1,y1;
  37. int x0=50, y0=150, x, y, h=10, r=2, d=3, l=4, u=1;
  38.  
  39. cout<<"Give the value of n\t";
  40. cin>>n;
  41. x=x0;
  42. y=y0;
  43. int gd=DETECT, gm;
  44. initgraph(&gd,&gm,NULL);
  45. moveto(x,y);
  46. hilbert(r,d,l,u,n,h,x,y);
  47. getch();
  48. closegraph();
  49. return 0;
  50. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.c:4:1: error: unknown type name ‘using’
 using namespace std;
 ^~~~~
prog.c:4:17: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘std’
 using namespace std;
                 ^~~
prog.c:6:29: error: expected ‘;’, ‘,’ or ‘)’ before ‘&’ token
 void move(int j, int h, int &x, int &y)
                             ^
prog.c:19:60: error: expected ‘;’, ‘,’ or ‘)’ before ‘&’ token
 void hilbert(int r, int d, int l, int u, int i, int h, int &x, int &y)
                                                            ^
prog.c: In function ‘main’:
prog.c:39:2: error: ‘cout’ undeclared (first use in this function)
  cout<<"Give the value of n\t";
  ^~~~
prog.c:39:2: note: each undeclared identifier is reported only once for each function it appears in
prog.c:40:2: error: ‘cin’ undeclared (first use in this function); did you mean ‘main’?
  cin>>n;
  ^~~
  main
prog.c:43:9: error: ‘DETECT’ undeclared (first use in this function)
  int gd=DETECT, gm;
         ^~~~~~
prog.c:44:2: error: implicit declaration of function ‘initgraph’ [-Werror=implicit-function-declaration]
  initgraph(&gd,&gm,NULL);
  ^~~~~~~~~
prog.c:45:2: error: implicit declaration of function ‘moveto’ [-Werror=implicit-function-declaration]
  moveto(x,y);
  ^~~~~~
prog.c:46:2: error: implicit declaration of function ‘hilbert’ [-Werror=implicit-function-declaration]
  hilbert(r,d,l,u,n,h,x,y);
  ^~~~~~~
prog.c:47:2: error: implicit declaration of function ‘getch’; did you mean ‘getc’? [-Werror=implicit-function-declaration]
  getch();
  ^~~~~
  getc
prog.c:48:2: error: implicit declaration of function ‘closegraph’ [-Werror=implicit-function-declaration]
  closegraph();
  ^~~~~~~~~~
prog.c:36:12: error: unused variable ‘y1’ [-Werror=unused-variable]
  int n, x1,y1;
            ^~
prog.c:36:9: error: unused variable ‘x1’ [-Werror=unused-variable]
  int n, x1,y1;
         ^~
cc1: all warnings being treated as errors
stdout
Standard output is empty