C/Visual C - estructuras. porfavor

 
Vista:

estructuras. porfavor

Publicado por princess (1 intervención) el 01/02/2007 19:28:06
Bueno tengo este codigo, mi duda es como le hago para que antes de salir de la aplicacion m e muestre los datos en pantalla. agradeceria toda su ayuda.

#include "iostream.h"

struct cliente
{
char nombre[50];
char direccion[50];
int DNI;
};
struct boleto
{
char placa[50];
char chofer[50];
double costo;
char origen[50];
char destino[50];
cliente asiento[4];
};

void Empresa (boleto autobus[2])
{
int i;
for( i=0;i<2;i++)
{

for(int j=0;j<4;j++)
{
cout<<" AUTOBUS "<<" "<<i+1<<" "<<endl;
cout<<"*******DATOS PERSONALES*******"<<endl;
cout<<"NOMBRE:"<<autobus[i].asiento[j].nombre<<endl;
cout<<"DIRECCION:"<<autobus[i].asiento[j].direccion<<endl;
cout<<"DNI:"<<autobus[i].asiento[j].direccion<<endl;
cout<<"NUMERO DE BOLETO:"<<"0"<<"0"<<j+1<<endl;
cout<<"******DATOS DEL VEHICULO******"<<" "<<i+1<<" "<<endl;
cout<<"PLACA:"<<autobus[i].placa<<endl;
cout<<"CHOFER:"<<autobus[i].chofer<<endl;
cout<<"COSTO:"<<autobus[i].costo<<endl;
cout<<"ORIGEN:"<<autobus[i].origen<<endl;
cout<<"DESTINO:"<<autobus[i].destino<<endl;
}
}

}
void main()
{

boleto autobus[2];

for(int i=0;i<2;i++)
{
cout<<"INGRESE DATOS DE LAS PERSONAS DEL AUTOBUS"<<" "<<i+1<<" "<<endl;
for(int j=0;j<4;j++)
{

cout<<"Ingrese nombre:"<<endl;
cin>> autobus[i].asiento[j].nombre;
cout<<"Ingrese direccion:"<<endl;
cin>> autobus[i].asiento[j].direccion;
cout<<"Ingrese DNI:"<<endl;
cin>> autobus[i].asiento[j].DNI;
cout<<"Numero de boleto:"<<endl;
cout<<"0"<<"0"<<j+1<<endl;
}
}
for( i=0;i<2;i++)
{
cout<<"INGRESE DATOS DEL VEHICULO"<<" "<<i+1<<" "<<endl;
cout<<"Ingrese placa:"<<endl;
cin>> autobus[i].placa;
cout<<"Ingrese chofer:"<<endl;
cin>> autobus[i].chofer;
cout<<"Ingrese costo:"<<endl;
cin>> autobus[i].costo;
cout<<"Ingrese origen:"<<endl;
cin>> autobus[i].origen;
cout<<"Ingrese destino:"<<endl;
cin>> autobus[i].destino;



}

Empresa(autobus);
}
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

RE:estructuras. porfavor

Publicado por maree (15 intervenciones) el 02/02/2007 16:41:26
Hola aca te dejo tu codigo con algunas modificaciones

#include "iostream.h"
#include "conio.h"

struct cliente
{
char nombre[50];
char direccion[50];
int DNI;
};
struct boleto
{
char placa[50];
char chofer[50];
double costo;
char origen[50];
char destino[50];
cliente asiento[4];
};

void Empresa (boleto autobus[2])
{
int i, j;
for( i=0;i<2;i++)
{

for( j=0;j<4;j++)
{
cout<<" AUTOBUS "<<" "<<i+1<<" "<<endl;
cout<<"*******DATOS PERSONALES*******"<<endl;
cout<<"NOMBRE:"<<autobus[i].asiento[j].nombre<<endl;
cout<<"DIRECCION:"<<autobus[i].asiento[j].direccion<<endl;
cout<<"DNI:"<<autobus[i].asiento[j].DNI<<endl;
cout<<"NUMERO DE BOLETO:"<<"0"<<"0"<<j+1<<endl;
cout<<"******DATOS DEL VEHICULO******"<<" "<<i+1<<" "<<endl;
cout<<"PLACA:"<<autobus[i].placa<<endl;
cout<<"CHOFER:"<<autobus[i].chofer<<endl;
cout<<"COSTO:"<<autobus[i].costo<<endl;
cout<<"ORIGEN:"<<autobus[i].origen<<endl;
cout<<"DESTINO:"<<autobus[i].destino<<endl;
}
}

}
void main()
{
int j, i;
boleto autobus[2];

clrscr();
for(i=0;i<2;i++)
{
cout<<endl<<"INGRESE DATOS DE LAS PERSONAS DEL AUTOBUS"<<" "<<i+1<<" "<<endl<<endl;
for(j=0;j<4;j++)
{

cout<<"Ingrese nombre: ";
cin>> autobus[i].asiento[j].nombre;
cout<<"Ingrese direccion: ";
cin>> autobus[i].asiento[j].direccion;
cout<<"Ingrese DNI: ";
cin>> autobus[i].asiento[j].DNI;
cout<<"Numero de boleto: ";
cout<<"0"<<"0"<<j+1<<endl<<endl;
}
}
for( i=0;i<2;i++)
{
cout<<"INGRESE DATOS DEL VEHICULO"<<" "<<i+1<<" "<<endl<<endl;
cout<<"Ingrese placa: ";
cin>> autobus[i].placa;
cout<<"Ingrese chofer: ";
cin>> autobus[i].chofer;
cout<<"Ingrese costo: ";
cin>> autobus[i].costo;
cout<<"Ingrese origen: ";
cin>> autobus[i].origen;
cout<<"Ingrese destino: ";
cin>> autobus[i].destino;
cout<<endl<<endl;


}

Empresa(autobus);
getch();
}

Espero te sirva, bye..
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar