Integridad de la programación Vbs
# include ltgraphics.h gt
# include ltstdio.h gt
void move _ step();
void Hanoi _ torre();
void init_hanoi_tower().
int m, n, mark = 1;
int w[3]={0, 0, 0};
Tamaño int sin signo
p>void *buf, *buf1, *buf 2;
void main()
{int driver=VGA, modo = 2;
init gráfico(& driver ampmode, "c:\\TC");
setbkcolor(0);
establecer color(15);
setfillstyle (1, 7);
clear device();
printf("El número de discos es: "); ampm); si (m lt1 | , marca de amplificador); si (marca gt3 | | marca lt1) salida(0); m);
hanoi_tower(m,'A','B','C');
getchar();
closegraph();
}
/************************************ ******* *****/
void inicialization_Hanoi_Tower (int m)
{ int I;
setfillstyle(1,7) ;establecer color (1;
setviewport(100, 80, 540, 300, 1);
Relleno (1, 1, 7); setfillstyle (1, 6);
Barra (40, 160, 120, 170);
Barra (75, 170); 17, 85, 159); Barra (215, 17, 225, 159); Barra (355, 17, 365, 159); )
{setfillstyle(1, (8 I) 16);
barra(75-i*5, 17 i*3, 85 i*5, 27 I * 13) ;
}
settextstyle(0, 0, 2)
outtextxy(80-8, 175, "A"); p> outtextxy(220-8, 175, "B");
outtextxy(360-8, 175, "C");
tamaño=tamañoimagen(25, 17, 135, 27);
buf 1 =(void *)malloc(tamaño);
getimage(140 25, 17, 140 135, 27, buf 1);
buf 2 =(void *)malloc(tamaño);
getinmage(25, 4, 135, 14, buf 2);
buf =(void *) malloc( tamaño);
}
/****************************** ******* **
****************/
void hanoi_tower(int m, char uno, char dos, char tres)
{if(m = =1)move_step(uno, tres);
else{hanoi_tower(m-1, uno, tres, dos);
move_stept(uno, tres);
Torre_Hanoi (m-1, dos, uno, tres);
}
}
/******** * *****************************************/
void move_step(char getone, char putone)
{void *buf3, buf4
char c[7];
int i, j, k, x , y;
Unsigned int s,ss;
Interruptor (dos en uno)
{
Caso "a": k = 11-w[0]; x = 0; w[0]-; romper;
Caso "b": k = 11-w[1]; p>Caso "c": k = 11-w[2];x = 280w[2]-;Romper;
}
getimage(25 x, 17 k*13 , 135 x, 27 k*13, buf);
putimage(25 x, 17 k*13, buf1, COPY _ PUT);
{ for(k-;k gt=0;k-)
{putimage(25x,17k*13,buf1, COPY_PUT);
for (I = 0;i lt32767;i)for(j = 0j lt;1000;j);
putimage(25 x, 17 k* 13,buf1,COPY_PUT);
}
putimage(25 x, 4,buf,COPY_PUT);
if(putone = = ' A ')k = 25;
si no (putone = = ' B ')k = 25 140;
else k = 25 280;
if(x lt; k)
for(y = x 20; y ltk-20; y =20)
{putimage(25 y-20, 4, buf2, COPY _ PUT);
putimage(25 y, 4 , buf, COPY _ PUT);
para (I = 0; i lt32767; i ) para (j = 0j lt; 1000; j
}
);for(y = x-20; y gt= k; y-=20)
{putimage(25 y -20,4,buf2,COPY_PUT);
putimage(25y,4,buf,COPY_PUT);
for(I = 0;ilt32767;i )for(j = 0j lt; 1000; j
}); p>
}
Interruptor (botón)
{Ejemplo" a”: k = 10-
w[0];x = 0;w[0]-;break;
Caso "b": k = 10-w[1];
Caso "c": k = 10-w[2]; x = 280w[2]-; romper;
}
Si (marca= =3)
putimage( 25 x, 4, buf2, COPY _ PUT);
for(y = 0; y ltk-1; y)
putimage(25 x, 17 y*13, buf1, COPY _ PUT);
}
}
putimage(25 x , 17 k*13, buf, COPY _ PUT);
establecer color(15); settextstyle(0, 0, 0);
setviewport(0, 320, 639, 479, 1); >si (n==0)
{ si (m lt; 10) { c[0]= m 10 48; c[1]= m 10 48; '; }
outtext("pasos en movimiento"); outtext(c);
outtext(" diskers: ");
k = n 1;
ss=imagersize(31*8, 0, 31*8 31, 14);
buf 4 =(void *)malloc(ss); );
getimage(31*8, 031*8 31, 14, buf 4);
if(k lt; 10)
{ c[ 0]= k 48; c[1]= ' \ 0 ';
}
si no(k lt; 100 ){ c[0]= k/10 48; c[1]= k 10 48; c[2]= ' \ 0 '; }
si no(k lt; 1000){ c[ 0]= k/100 k = 100; c[1]= K/10 48;
c[2]= k 10 48; c[3]= ' \ 0 ';}
si no { c[0] = k/1000 48; c[2]= k/10 48; c[3] = k 10 48; c[4]= '\0';}
putimage(31*8, 0buf4, XOR_PUT);
outtextxy(31*8,0,c);
Gratis(buf 4);
/****************** ************** **************************/
c[0]=getone=='A '? 'A':getone=='B'? b ':' C ';
c[1]= '-'; c[2]= '-'; c[3]= '-'; ;c[6]= '\ 0 '; c[5]=putone=='A '?
'A':putone=='B'? b':' C';
x = n 8 * 80
y = 8/8 * 15 15;
if(n/8 gt; =10)
{ y = 80/8 * 15;
if(x==0){s=tamañoimagen(0, 16, 639, 159); >
buf 3 =(void *)mallco(s);
for(I = 0;ilt15;i)
{getimage(0, 16, 639, 159 , buf 3);
putimage(0, 15, buf3, COPY_PUT);
}
Gratis (buf 3);
}
}
outtextxy(x, y, c);
n;
if(marca = = 2 amp; amp(n lt80||x!=0))
for(I = 0;i lt32767;i)for(j = 0;j lt1000;j);
setviewport (100, 80, 540, 300, 1)
}
Calendario
/*Calendario de salida*/
# incluir); ltstdio.h gt
Año bisiesto (año entero)
{ if(año 400 == 0 | | año 100!= 0 amp amp año 4==0)
Return(1);
Otros
return(0);
}
void main() p>
{int año;
salida nula (int);
while(1)
{printf("Ingrese el año: " );
scanf("d ", amp año);
Salida (año);
printf("¿Continuar? (s/n)" ) ; getchar(); getchar();
if(getchar()!= ' y ' ampgetchar()!= 'Y ') desconectar
} p>
}
Resultado no válido (entre años)
{ int a[12]={31, 28, 31, 30, 31, 30, 31, 30, 31, 30, 31};
int i, j=0, t, p, count
suma larga = 0;
char mes[][12 ] ={{'J','A','N'},{'F','E','B'},{'M','A','R'},{'M', ' A', 'Y'}, {'J', 'U', 'N'}, {'J', 'U', 'L'}, {'A', 'U', 'G'} , {'S','E','P'},{'O','C','T'},{'N','O','V'},{ '
if(AÑO bisiesto (AÑO))a[1]= 29;
for(I = 0; i año bisiesto; i )
{if (año bisiesto)
suma = suma 366;
Otros
suma = suma 365;
>}
p = (suma 1) 7;
cuenta = p;
para(I = 0; i lt12; i )
{
printf(" \ n-\ n ");
printf("**s** \n ",mes[I]);
printf("Lunes, Martes, Miércoles, Jueves, Viernes, Sábado y Domingo\ n "
printf("-\ n "); t = 0; t lt cuenta; t )
{ printf(" "
}
for(j = 1; j lta[I] 1; j )
{ printf("3d ", j);
cuenta
cuenta = cuenta 7; (cuenta 7 ==0)
printf(" \ n ");
p = cuenta }
}
Regresar; ;
p>}
Conjetura de Goldbach
#Contiene “stdio.h”
#Contiene “math.h” p>
main()
{ int a, b, c, d;
printf("Ingrese un número:
); scanf(" d ", ampa);
for(b = 3; b lt= a/2; b =2)
{ for(c = 2; c lt= sqrt(b c )
si(b c = = 0)romper;
if(c gt;sqrt(b))
d = a-b ;
p>
Otro
Descanso;
for(c = 2; c lt= sqrt(d); c )
si(d c = = 0)romper;
if(c gt;sqrt(d))
printf("d=d d\n ",a,b, d);
}
getchar();
}