Author Topic: Just hang on one week  (Read 1568 times)

Huginn the crow

  • Traveller
  • *
  • Posts: 20
    • View Profile
Just hang on one week
« on: July 15, 2003, 11:39:34 pm »
This week i have exams of calculus, advanced algebra, programming and analitic geometry.
If someone start it, i\'ll be glad to join it, if not, i\'ll do it the next week.

By the way, if someone study math, and know the C language, try to run this code. It draws Hilbert\'s curves.

#include
#include
#include
#include
void graficos ();
void inicio ();
void linea (char,int,int*,int*);
void curvaA (int,int,int*,int*);
void curvaB (int,int,int*,int*);
void curvaC (int,int,int*,int*);
void curvaD (int,int,int*,int*);

void main (){
graficos();
do{cleardevice();
inicio();
printf(\"Otra vez? (S/N)\");
}while(toupper(getche())==\'S\');
closegraph;
}

void graficos (){
int gdriver=DETECT,gmode;
initgraph(&gdriver,&gmode,\"h:\\\\bgi\");
}

void curvaA (int c,int t,int*x,int*y){
if (c>0){curvaD(c-1,t,x,y);
   linea(\'O\',t,x,y);
     curvaA(c-1,t,x,y);
      linea(\'S\',t,x,y);
     curvaA(c-1,t,x,y);
      linea(\'E\',t,x,y);
     curvaB(c-1,t,x,y);}}

void curvaB (int c,int t,int*x,int*y){
if (c>0){curvaC(c-1,t,x,y);
   linea(\'N\',t,x,y);
     curvaB(c-1,t,x,y);
      linea(\'E\',t,x,y);
     curvaB(c-1,t,x,y);
      linea(\'S\',t,x,y);
     curvaA(c-1,t,x,y);}}

void curvaC (int c,int t,int*x,int*y){
if (c>0){curvaB(c-1,t,x,y);
   linea(\'E\',t,x,y);
     curvaC(c-1,t,x,y);
      linea(\'N\',t,x,y);
     curvaC(c-1,t,x,y);
      linea(\'O\',t,x,y);
     curvaD(c-1,t,x,y);}}

void curvaD (int c,int t,int*x,int*y){
if (c>0){curvaA(c-1,t,x,y);
   linea(\'S\',t,x,y);
     curvaD(c-1,t,x,y);
      linea(\'E\',t,x,y);
     curvaD(c-1,t,x,y);
      linea(\'N\',t,x,y);
     curvaC(c-1,t,x,y);}}

void linea (char dir, int t, int *x, int *y)
{switch (dir){
    case \'N\':line(*x,*y,*x,*y-t);
     *y=*y-t;
        break;
  case \'S\':line(*x,*y,*x,*y+t);
     *y=*y+t;
        break;
  case \'E\':line(*x,*y,*x+t,*y);
     *x=*x+t;
        break;
  case \'O\':line(*x,*y,*x-t,*y);
     *x=*x-t;
        break;
}}

void inicio ()
{
 char t;
 signed int i,j,k,l;
 do{
 printf(\"Que tipo de curva quieres? (A/B/C/D)\\n\");
  t=toupper(getche());
    if(t!=\'A\'&&t!=\'B\'&&t!=\'C\'&&t!=\'D\')printf(\"\\nOpcion no valida\\n\");
   }while(t!=\'A\'&&t!=\'B\'&&t!=\'C\'&&t!=\'D\');
 do{
 printf(\"\\nQue orden de curva quieres? (menor a 21)\\n\");
 scanf(\"%d\",&i);
   if(i>21) printf(\"Opcion no valida\\n\");}while(i>21);
 do{
    printf(\"Que tamano de curva quieres? (menor a 19)\\n\");
 scanf(\"%d\",&j);
   if(j>19) printf(\"Opcion no valida\\n\");}while(j>19);
 do{
    printf(\"Dame el punto inicial x, menor a %d\\n\",getmaxx()/2);
   scanf(\"%d\",&k);
   if(k>(getmaxx()/2)) printf(\"Opcion no valida\\n\");
  }while(k>(getmaxx()/2));
 do{
    printf(\"Dame el punto inicial y, menor a %d\\n\",getmaxy()/2);
   scanf(\"%d\",&l);
   if(l>(getmaxy()/2)) printf(\"Opcion no valida\\n\");
  }while(l>(getmaxy()/2));
 switch (t){
    case \'A\':curvaA(i,j,&k,&l);break;
 case \'B\':curvaB(i,j,&k,&l);break;
 case \'C\':curvaC(i,j,&k,&l);break;
 case \'D\':curvaD(i,j,&k,&l);break;
 }
getch();
}
« Last Edit: July 17, 2003, 01:44:13 am by Huginn the crow »
The black wind is blowing...

Moogie

  • Forum Legend
  • *
  • Posts: 4551
  • Artist/Flash Animator
    • View Profile
(No subject)
« Reply #1 on: July 16, 2003, 01:06:26 am »
Should\'ve disabled smileys in that post... you can edit and uncheck the box. That\'ll clear up the bits of code that got messed up due to ; ) symbols.

druke

  • Hydlaa Notable
  • *
  • Posts: 965
    • View Profile
(No subject)
« Reply #2 on: July 16, 2003, 04:19:16 am »
hmm i am a bit new to c++ where can i DL graphics.h?


my how times have changed.....

Moogie

  • Forum Legend
  • *
  • Posts: 4551
  • Artist/Flash Animator
    • View Profile
(No subject)
« Reply #3 on: July 16, 2003, 02:58:28 pm »
Quote
Originally posted by druke
hmm i am a bit new to c++ where can i DL graphics.h?


That code is C, not C++. As far as I know, graphics.h should already exist in your system. The #include lines tell the application to read those files and remember variables stated within them for use in the current routine.

I like programming. :)

[Edit: ...but I wish I could read the language it uses. Is that Italian??]
« Last Edit: July 16, 2003, 03:00:56 pm by Moogie »

Keldorn

  • Hydlaa Notable
  • *
  • Posts: 818
    • View Profile
(No subject)
« Reply #4 on: July 16, 2003, 03:15:48 pm »
Quote
Originally posted by Mogura
I like programming. :)

You never cease to amaze me ;)

I think that language is Spanish btw. Otra vez? for example means something like: Again?
m.vanes

Huginn the crow

  • Traveller
  • *
  • Posts: 20
    • View Profile
(No subject)
« Reply #5 on: July 17, 2003, 01:42:05 am »
It\'s spanish (my mother\'s language), and Keldorn is right.
About the libraries, graphics.h it\'s only in the C languages designed for DOS, not in the windows ones.
I\'m also amazed that you can diferenciate between function and object codes, what do you study guys?

If u\'re interested in Analithic Geometry visit:
http://combinatoria.matem.unam.mx/roli/
It\'s in spanish, but there are animations that run in Java and it\'s very cool to see a Moebius Linear transformation; or a projection from 4 to 4

PD. Maybe you find this interesting Mogura:
http://simplyff.free.fr/FF6/Test/mog.jpg

PD2. I\'ve done the programming and Analitic exams :)
« Last Edit: July 17, 2003, 01:43:49 am by Huginn the crow »
The black wind is blowing...

Moogie

  • Forum Legend
  • *
  • Posts: 4551
  • Artist/Flash Animator
    • View Profile
(No subject)
« Reply #6 on: July 17, 2003, 02:34:05 am »
Nice Moogle pic. :)