Advertisement
link186fr

Autobus Tickets

Dec 29th, 2014
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.83 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int main()
  4. {
  5.   int asiento[12]={0};
  6.   int x, y;
  7.   printf("Los estados de los asientos son: Libre=0, Vendido=1.n" );
  8.   do
  9.     {
  10.       printf("\nCual asiento quieres comprar?: " );
  11.       scanf("%d",&y);
  12.       if(y==0)break;
  13.       else if(y<=0 || y>=13)
  14.       printf("\nAsiento fuera del rango del autobus." );
  15.       else if(asiento[y-1]==1)
  16.       printf("\nAsiento ya vendido" );
  17.       else
  18.       {
  19.         asiento[y-1]=1;
  20.       {
  21.         for(x=0; x<12; x++)
  22.         {
  23.           if(!(x%2))
  24.           printf("\nAsiento %d= %d",x+1,asiento[x] );
  25.      else printf("\tAsiento %d= %d",x+1,asiento[x] );
  26.          }
  27.       }
  28.    }
  29. }
  30.    while(1);
  31.    if(asiento[12]==1)
  32.     printf(" Todos los asientos se han vendido." );
  33.     else printf("\nGracias por usar este programa." );
  34.     //getch();
  35.     return 0;
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement