EL CLASICO DE SNAKE

SIGUE-LINEAS versión BETA

Sigue-lineas versión 2.0

domingo, 30 de septiembre de 2007

PROGRAMA QUE CREA UNA COLA EN 'C'.

#include"stdio.h"
#include"conio.h"
int col[5],c_cola=0,x;
main ()
{
int op;
clrscr();
do
{
printf("\n\nMENU\n1.-INSETAR\n2.-EXTRAER\n3.-IMPRIMIR\n4.-SALIR\nOPCION: ");
scanf("%d",&op);
switch (op)
{
case 1:
clrscr();
if(c_cola<5){
printf("\nvalor: ");
scanf("%d",&col[c_cola]);
c_cola++;
}
else
printf("\nla cola esta llena ");
break;
case 2:
clrscr();
if(col>0)
{
if(c_cola==0)
{
printf("La cola esta vacia");
}
for(x=0; x<5; x++)
{
col[x]=col[x+1];
}
c_cola--;
}
else
printf("\cola vacia");
break;
case 3:
clrscr();
int x,y;
printf("\ncontenido de la cola : ");
for(x=0;x printf("\n%d",col[x]);
for(y=x;y<5;y++)
printf("\nNULL");
break;
case 4:
printf("\nsalir");
}}
while(op!=4);
getch();
}