EL CLASICO DE SNAKE

SIGUE-LINEAS versión BETA

Sigue-lineas versión 2.0

martes, 25 de septiembre de 2007

PROGRAMACIÓN EN TURBO C QUE REALIZA EL METODO DE LA BURBUJA: ASCENDENTEMENTE Y DESCENDENTEMENTE.

# include"stdio.h""
# include"conio.h"

int y,auxnum,i,j,x;
int num[10];
void mayor()
{
//clrscr();
x=11;
//printf("ORDENA LOS NUMEROS DE MAYOR A MENOR\n");
for (y=1;y<11;y++)
{
printf("teclea los numeros %d:",y);
scanf("%d",&num[y]);
}
getch ();
clrscr ();
for (i=1;i for (j=1;j {
if(num[j] {
auxnum=num[j];
num[j]=num[j+1];
num[j+1]=auxnum;
}
}
for (int j=1;j<11;j++)
{
gotoxy(13,j+2);printf("los numeros son:%d",num[j]);
}
getch();
}
void menor()
{
clrscr();
x=11;
//printf("ORDENA LOS NUMEROS DE MAYOR A MENOR\n");
for (y=1;y<11;y++)
{
printf("teclea los numeros %d:",y);
scanf("%d",&num[y]);
}
getch ();
clrscr ();
for (i=1;i for (j=1;j {
if(num[j]>num[j+1])
{
auxnum=num[j];
num[j]=num[j+1];
num[j+1]=auxnum;
}
}
for (int j=1;j<11;j++)
{
gotoxy(13,j+2);printf("los numeros son:%d",num[j]);
}
getch();
}

int menu()
{ int op;
clrscr();
printf("<>\n1.-MAYOR A MENOR\n2.-MENOR MAYOR\n3.-SALIR\nopcion?:");
scanf("%d",&op);
return op;

}
main()
{//llave del main
int op;
clrscr();
do{
op=menu();
switch(op)
{
case 1:
clrscr();
mayor();
break;
case 2:
menor();
break;
case 3:
printf("\nsaliendo del programa......");
getch();
break;
}} while(op!=3);
}