Guest User

Untitled

a guest
Oct 23rd, 2018
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.06 KB | None | 0 0
  1. #include <iostream>
  2. #include <conio.h>
  3. #include <windows.h>
  4. #include <stdlib.h>
  5. #include <stdio.h>
  6. #include <math.h>
  7. using namespace std;
  8.  
  9. char avion[4][25];
  10. int opcion, asientos, fila, col;
  11.  
  12. int imprimir(){
  13. system("color f");
  14. system("cls");
  15. cout<<"<< Asientos del avion >>"<<endl;
  16. for (int a=0; a<4; a++){
  17. for (int b=0; b<25; b++){
  18. cout<<"["<<avion[a][b]<<"]";
  19. }
  20. cout<<endl;
  21. }
  22. return 0;
  23. }
  24.  
  25. int main (){
  26.  
  27. for (int a=0; a<4; a++){
  28. for (int b=0; b<25; b++){
  29. avion[a][b]=' ';
  30. }
  31. }
  32. cout<<endl;
  33. cout<<"Bienvenido a Fercho Aerolineas"<<endl;
  34.  
  35. do {
  36. do {
  37. cout<<endl;
  38. cout<<"[ 1 ] Reservar asientos."<<endl;
  39. cout<<"[ 2 ] Cancelar asientos."<<endl;
  40. cout<<"[ 3 ] Salir."<<endl;
  41. cout<<endl;
  42. cout<<"Seleccione una opcion: "; cin>>opcion;
  43.  
  44. if (opcion<1 || opcion>3){
  45. system("cls");
  46. system("color c");
  47. cout<<endl<<"Opcion incorrecta, intente otra vez."<<endl;
  48. }
  49. } while(opcion<1 || opcion>3);
  50.  
  51. switch (opcion) {
  52. case 1:
  53. system("cls");
  54. imprimir();
  55. cout<<endl;
  56. do {
  57. cout<<"Digite el numero de asientos a reservar: "; cin>>asientos;
  58. if (asientos<1 || asientos>10){
  59. cout<<"No es posible agregar este numero de asientos, intente otra vez."<<endl;
  60. }
  61. } while(asientos<1 || asientos>10);
  62.  
  63. for (int c=1; c<=asientos; c++){
  64. do {
  65. cout<<endl;
  66. cout<<"Digite el numero de fila: "; cin>>fila;
  67. cout<<"Digite el numero de columna: "; cin>>col;
  68.  
  69. if (fila<0 || col<0 || fila>3 || col>24){
  70. cout<<"Las coordenadas de su asiento son incorrectas."<<endl;
  71. }
  72. if (avion[fila][col]=='x'){
  73. cout<<"Este asiento ya esta ocupado, intente otra vez."<<endl;
  74. }
  75.  
  76. } while(fila<0 || col<0 || fila>3 || col>24 || avion[fila][col]=='x');
  77.  
  78. avion[fila][col]='x';
  79. imprimir();
  80. }
  81. system("color a");
  82. cout<<endl;
  83. cout<<"Asientos agregados satisfactoriamente!"<<endl;
  84. Sleep(2000);
  85. system("color f");
  86.  
  87. break;
  88. case 2:
  89. system("cls");
  90. imprimir();
  91. cout<<endl;
  92. do {
  93. cout<<"Digite el numero de asientos a cancelar: "; cin>>asientos;
  94. if (asientos<1 || asientos>10){
  95. cout<<"No es posible cancelar este numero de asientos, intente otra vez."<<endl;
  96. }
  97. } while(asientos<1 || asientos>10);
  98.  
  99. for (int c=1; c<=asientos; c++){
  100. do {
  101. cout<<endl;
  102. cout<<"Digite el numero de fila: "; cin>>fila;
  103. cout<<"Digite el numero de columna: "; cin>>col;
  104.  
  105. if ((fila<0 && col<0) || (fila>3 && col>24)){
  106. cout<<"Las coordenadas de su asiento son incorrectas."<<endl;
  107. }
  108. if (avion[fila][col]==' '){
  109. cout<<"Este asiento no ha sido ocupado, intente otra vez."<<endl;
  110. }
  111.  
  112. } while((fila<0 && col<0) || (fila>3 && col>24) || avion[fila][col]==' ');
  113.  
  114. avion[fila][col]=' ';
  115. imprimir();
  116. }
  117. system("color a");
  118. cout<<endl;
  119. cout<<"Asientos cancelados satisfactoriamente!"<<endl;
  120. break;
  121. }
  122.  
  123.  
  124. } while(opcion!=3);
  125.  
  126. cout<<endl;
  127. cout<<"Gracias por volar con nosotros!"<<endl;
  128.  
  129.  
  130.  
  131. getch();
  132. return 0;
  133. }
Add Comment
Please, Sign In to add comment