Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <conio.h>
- #include <windows.h>
- #include <stdlib.h>
- #include <stdio.h>
- #include <math.h>
- using namespace std;
- char avion[4][25];
- int opcion, asientos, fila, col;
- int imprimir(){
- system("color f");
- system("cls");
- cout<<"<< Asientos del avion >>"<<endl;
- for (int a=0; a<4; a++){
- for (int b=0; b<25; b++){
- cout<<"["<<avion[a][b]<<"]";
- }
- cout<<endl;
- }
- return 0;
- }
- int main (){
- for (int a=0; a<4; a++){
- for (int b=0; b<25; b++){
- avion[a][b]=' ';
- }
- }
- cout<<endl;
- cout<<"Bienvenido a Fercho Aerolineas"<<endl;
- do {
- do {
- cout<<endl;
- cout<<"[ 1 ] Reservar asientos."<<endl;
- cout<<"[ 2 ] Cancelar asientos."<<endl;
- cout<<"[ 3 ] Salir."<<endl;
- cout<<endl;
- cout<<"Seleccione una opcion: "; cin>>opcion;
- if (opcion<1 || opcion>3){
- system("cls");
- system("color c");
- cout<<endl<<"Opcion incorrecta, intente otra vez."<<endl;
- }
- } while(opcion<1 || opcion>3);
- switch (opcion) {
- case 1:
- system("cls");
- imprimir();
- cout<<endl;
- do {
- cout<<"Digite el numero de asientos a reservar: "; cin>>asientos;
- if (asientos<1 || asientos>10){
- cout<<"No es posible agregar este numero de asientos, intente otra vez."<<endl;
- }
- } while(asientos<1 || asientos>10);
- for (int c=1; c<=asientos; c++){
- do {
- cout<<endl;
- cout<<"Digite el numero de fila: "; cin>>fila;
- cout<<"Digite el numero de columna: "; cin>>col;
- if (fila<0 || col<0 || fila>3 || col>24){
- cout<<"Las coordenadas de su asiento son incorrectas."<<endl;
- }
- if (avion[fila][col]=='x'){
- cout<<"Este asiento ya esta ocupado, intente otra vez."<<endl;
- }
- } while(fila<0 || col<0 || fila>3 || col>24 || avion[fila][col]=='x');
- avion[fila][col]='x';
- imprimir();
- }
- system("color a");
- cout<<endl;
- cout<<"Asientos agregados satisfactoriamente!"<<endl;
- Sleep(2000);
- system("color f");
- break;
- case 2:
- system("cls");
- imprimir();
- cout<<endl;
- do {
- cout<<"Digite el numero de asientos a cancelar: "; cin>>asientos;
- if (asientos<1 || asientos>10){
- cout<<"No es posible cancelar este numero de asientos, intente otra vez."<<endl;
- }
- } while(asientos<1 || asientos>10);
- for (int c=1; c<=asientos; c++){
- do {
- cout<<endl;
- cout<<"Digite el numero de fila: "; cin>>fila;
- cout<<"Digite el numero de columna: "; cin>>col;
- if ((fila<0 && col<0) || (fila>3 && col>24)){
- cout<<"Las coordenadas de su asiento son incorrectas."<<endl;
- }
- if (avion[fila][col]==' '){
- cout<<"Este asiento no ha sido ocupado, intente otra vez."<<endl;
- }
- } while((fila<0 && col<0) || (fila>3 && col>24) || avion[fila][col]==' ');
- avion[fila][col]=' ';
- imprimir();
- }
- system("color a");
- cout<<endl;
- cout<<"Asientos cancelados satisfactoriamente!"<<endl;
- break;
- }
- } while(opcion!=3);
- cout<<endl;
- cout<<"Gracias por volar con nosotros!"<<endl;
- getch();
- return 0;
- }
Add Comment
Please, Sign In to add comment