martes, noviembre 28, 2006

De Nuevo Programando

Ja ja ja, que tal, pues si una vez mas me puse a programar, y pues esta vez trabaje con notacion polaca, con la ayuda de mi profesora y unos amigos, no es muy complicado lo que hice pero les dejo el codigo en estas clases:

Cabecera.java
Procesos.java
Final.java.

bueno esta es su apariencia.


Por otra parte, gracias por sus comentarios.

viernes, noviembre 10, 2006

lo poco de C

pues bien como lo prometido es deuda acá esta mi unicodigo de C
/*************************************************
*Alumno: Julian Ernesto Tun Ku *
*Profesor: Manuel Cervera *
*Materia: Topicos Selectos de Programacion *
*Grupo: 3 - B *
*Carrera: Ingenieria en Sistemas Computacionales *
*10:19 19/10/2006 *
*************************************************/

#include
#include
#include
#include
#include
#include "cursor.h"

#define CLIP_ON 1

class rata
{
public:
void initrata();
void Rapagado();
int BotonPres();
int BotonSult();
void Rencendido();
void inicia();
void procesos();
void fin();
void BSF();
void BCF();
int ejex();
int ejey();
int corxy();
int a,b,xy,a1,b1,x,y,dx,dy;
void punteros(const cursores &mc);
void punteros();

SREGS sregs;
REGS regs;
private:
union REGS r ;
};




int main(void)
{ rata rat1;
rat1.inicia();
}


void rata::initrata(void)
{
r.x.ax=0;
Rapagado();
Rencendido();
int86 (0X33,&r,&r);
int86 (0X33 ,&r,&r);
r.x.ax=3;
int86 (0X33 ,&r,&r);
a=r.x.cx;
b=r.x.dx;

}

void rata::Rapagado()
{
r.x.ax=2;
}

void rata::BCF()
{

setfillstyle(EMPTY_FILL+1,7);bar(291,131,349,149);
setcolor(15);
line(290,130,290,150);
line(290,130,350,130);
line(289,129,348,129);
line(289,129,289,148);


setcolor(8);

line(290,150,350,150);
line(350,130,350,150);
line(291,151,351,151);
line(351,131,351,151);
line(292,152,352,152);
line(352,132,352,152);
line(288,128,347,128);
line(288,128,288,147);

}

void rata::BSF()
{

setfillstyle(EMPTY_FILL+1,7);bar(291,131,349,149);
setcolor(15);
line(290,130,290,150);
line(290,130,350,130);
setcolor(8);
line(290,150,350,150);
line(350,130,350,150);
}


void rata::Rencendido()
{
r.x.ax=1;
}

int rata::ejex()
{
a=r.x.cx;
return a;
}

int rata::ejey()
{
b=r.x.dx;
return b;
}

int rata::BotonPres()
{
a=ejex();
b=ejey();
if (r.x.bx==1)
return 1;
else
if (r.x.bx==2)
return 2;
}

int rata::BotonSult()
{
r.x.ax=6;
int86(0x33,&r,&r);
a1=ejex();
b1=ejey();
if (r.x.bx==1)
return 1;
else
if (r.x.bx==2)
return 2;
}

int rata::corxy()
{
xy=r.x.cx;
return xy;
}

void rata::inicia()
{
int gdriver = DETECT, gmode, errorcode;
rata rat;
/* initialize graphics mode */
initgraph(&gdriver, &gmode,"c:\\tc\\BGI");
/* read result of initialization */
errorcode = graphresult();
if (errorcode != grOk) /* an error occurred */
{
printf("Graphics error: %s\n", grapherrormsg(errorcode));
printf("Press any key to halt:");
getch();
exit(1); /* return with error code */
}


line((getmaxx()/2),gety(), (getmaxx()/2), getmaxy());
line(getx(),(getmaxy()/2),getmaxx(),(getmaxy()/2));

procesos();


}
void rata::procesos()

{

int i=EMPTY_FILL+1;
setfillstyle(i,9);bar(1,241,319,479);
setfillstyle(i,12);bar(322,241,639,479);
setfillstyle(i,6);bar(1,1,319,239);
setfillstyle(i,2);bar(321,1,639,239);
setbkcolor(6);
BSF();

do
{


//inicia el proceso de imprimir coordenadas en X
initrata();
x=ejex();
y=ejey();
setcolor(1);
setviewport(getx(),gety(),getmaxx(),getmaxy(),CLIP_ON);
char enx[30];
sprintf(enx,"F %d",ejex());
outtextxy(50,5,enx);



//inicia el proceso de imprimir coordenadas en Y
setviewport(getx(),gety(),getmaxx(),getmaxy(),CLIP_ON);
char eny[30];
sprintf(eny,"C %d",ejey());
outtextxy(150,5,eny);
if(x!=dx || y!=dy)
{
dx=x;
dy=y;

if (dx>290&&dx<350&&dy>130&&dy<150)
{
BCF();
}

if(dx>290&&dx<350&&dy>130&&dy<150)
{

BSF();
}
else
{
int i=EMPTY_FILL+1;
setfillstyle(i,2);bar(321,128,352,129);
setfillstyle(i,2);bar(351,130,352,152);
setfillstyle(i,2);bar(321,151,352,152);
setviewport(287,128,320,129,CLIP_ON); clearviewport();
setviewport(287,128,289,149,CLIP_ON); clearviewport();
setviewport(288,151,320,152,CLIP_ON); clearviewport();

}

setviewport(149,4,189,16,CLIP_ON); clearviewport();
setviewport(49,4,89,16,CLIP_ON); clearviewport();


}

//termina proceso de imprimir coordenadas en Y
setcolor(7);
//comienza proceso de detectar clic izquierdo
if (BotonPres()==1)
{
setviewport(getx(),gety(),getmaxx(),getmaxy(),CLIP_ON);
char BI[10];
sprintf(BI,"BI");
Rapagado();
outtextxy(ejex(),ejey(),BI);
BotonSult();

if (BotonSult()==0)
{
int l=ejex();
int p=ejey();
setviewport((l-1),(p-1),(l+15),(p+10),CLIP_ON);
Rapagado();
clearviewport();
}

if (dx>290&&dx<350&&dy>130&&dy<150)
{
exit(1);
}




}
//termina proceso de comparacion del boton izquierdo
else
//inicia proceso de comparacion de boton derecho
if (BotonPres()==2)
{ setcolor(15),
setviewport(getx(),gety(),getmaxx(),getmaxy(),CLIP_ON);
char BI[10];
sprintf(BI,"BD");
Rapagado();
outtextxy(ejex(),ejey(),BI);
BotonSult();

if (BotonSult()==0)
{
int l=ejex();
int p=ejey();
setviewport((l-1),(p-1),(l+15),(p+10),CLIP_ON);
Rapagado();
clearviewport();
}

}
punteros();
}while(!kbhit());

do{
dx=ejex();
dy=ejey();
if(dx>290&&dx<350&&dy>130&&dy<150)
BSF();


}while(!kbhit());

getch();
closegraph();

}


void rata::punteros()
{
x=ejex();
y=ejey();
if(x>0&&x<320&&y>0&&y<240)
punteros(mano);
if(x>320&&x<640&&y>0&&y<240)
punteros(defaul);
if(x>0&&x<320&&y>240&&y<480)
punteros(julian);
if(x>320&&x<640&&y>240&&y<480)
punteros(reloj);
if(x==0&&y==0||x==640&&y==480)
punteros(diagonali);
if(x==640&&y==0||x==640&&y==0)
punteros(diagonal);
if(x==0&&y>0&&y<480)
punteros(flechita1);
if(x==640&&y>0&&y<480)
punteros(flechita1);
if(x==320&&y>0&&y<480)
punteros(flechita1);
if(x>0&&x<640&&y==0)
punteros(flechita2);
if(x>0&&x<640&&y==480)
punteros(flechita2);
if(x>0&&x<640&&y==240)
punteros(flechita2);
if(x==320&&y==240)
punteros(cruz);
}

void rata:: punteros(const cursores &mc)
{
regs.x.ax=9;
regs.x.bx=mc.HotSpot.x;
regs.x.cx=mc.HotSpot.y;
regs.x.dx=FP_OFF(mc.sm);
sregs.es=FP_SEG(mc.sm);
int86x(0x33,®s,®s,&sregs);
}


tengo uno mas.

/*************************************************
*Alumno: Julian Ernesto Tun Ku *
*Profesor: Manuel Cervera *
*Materia: Topicos Selectos de Programacion *
*Grupo: 3 - B *
*Carrera: Ingenieria en Sistemas Computacionales *
*8:26 10/11/2006 *
*biosequip + herencia *
*************************************************/

#include
#include
#include
#include
#include

class BiosequiP
{
public:
void grafico();

};

void BiosequiP::grafico(void)
{
BiosequiP lol;
/* request auto detection */
int gdriver = DETECT, gmode, errorcode;

/* initialize graphics mode */
initgraph(&gdriver, &gmode, "c:\\tc\\BGI");

/* read result of initialization */
errorcode = graphresult();

if (errorcode != grOk) /* an error occurred */
{
printf("Graphics error: %s\n", grapherrormsg(errorcode));
printf("Press any key to halt:");
getch();
exit(1); /* return with error code */
}

}


class julian:public BiosequiP
{
public:
void process();
int boot,fpc,ram,inv,diskd,dma,com,game,print,para;
int reg;
};

void julian::process()
{

boot=reg&1;

gotoxy(5,6);
printf("Cargador del disco = %d",boot);
fpc=(reg&2)>>1;
gotoxy(5,7);
printf("Coprocesor de la coma flotante = %d",fpc);
ram=(reg&12)>>2;
gotoxy(5,8);
printf("Tama¤o de Ram de la placa base = %d",ram);
inv=(reg&48)>>4;
gotoxy(5,9);
printf("Modo de inicio de video = %d",inv);
diskd=(reg&192)>>6;
gotoxy(5,10);
printf("Disk drives = %d",diskd);
dma=(reg&(1<<7))>>7;
gotoxy(5,11);
printf("DMA = %d",dma);
com=(reg&(7<<9))>>9;
gotoxy(5,12);
printf("COM ports = %d",com);
game=(reg&(1<<12))>>12;
gotoxy(5,13);
printf("Game I/O = %d",game);
print=(reg&(1<<13))>>13;
gotoxy(5,14);
printf("Impresion serial = %d",print);
para=(reg&(3<<14))>>14;
gotoxy(5,15);
printf("Impresoras paralelas = %d",para);
gotoxy(20,18);
printf("Gracias por usar biosequip 1.0.01");
}

int main(void)
{
julian uno;
uno.process();
getch();
closegraph();
return 0;
}

pues bueno no es mucho, pero es lo que voy avanzando, por cierto pronto terminare el codigo de operaciones con arreglos de datos ordenados y ya lo pondre por acá.