Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- typedef struct
- {
- int numeroExpediente;
- char nombre [30];
- float cuotas[3];
- char sexo;
- int numeroHabitacion;
- char direccion[20];
- char obraSocial[20];
- } paciente;
- paciente cargarPaciente();
- void cargarPacienteConPuntero(paciente * punteroApaciente);
- int main()
- {
- /*
- paciente paciente1 = cargarPaciente();
- paciente paciente2 = cargarPaciente();
- mostrarPaciente(paciente1);
- mostrarPaciente(paciente2);
- paciente paciente3;
- cargarPacienteConPuntero(&paciente3);
- mostrarPaciente(paciente3);
- */
- int dim = 20;
- paciente consultorio[20]; //un arreglo de estructura
- int cantidadPacientes = cargarArreglo(consultorio,dim);
- mostrarConsultorio(consultorio,cantidadPacientes);
- return 0;
- }
- void mostrarConsultorio(paciente consultorio[20], int validos)
- {
- int indice;
- for (indice = 0;indice<validos;indice++)
- {
- //mostrarPaciente(consultorio[índice]);
- paciente pacAux = consultorio[indice];
- mostrarPaciente(pacAux);
- }
- }
- int cargarArreglo(paciente consultorio[20], int dim)
- {
- int cantidadPacientes = 0;
- char mander = 's';
- while ((mander == 's')&&(cantidadPacientes<dim))
- {
- //consultorio[cantidadPacientes] = cargarPaciente();
- paciente pacAux = cargarPaciente();
- consultorio[cantidadPacientes] = pacAux;
- cantidadPacientes++;
- printf("hay otro paciente?\n");
- fflush(stdin);
- scanf("%c",&mander);
- }
- return cantidadPacientes;
- }
- void cargarPacienteConPuntero(paciente * punteroApaciente)
- {
- printf("numeroExpediente\n");
- fflush(stdin);
- scanf("%d",&punteroApaciente->numeroExpediente);//super valida!!!
- printf("nombre\n");
- fflush(stdin);
- scanf("%s",&punteroApaciente->nombre);//super valida!!!
- printf("sexo\n");
- fflush(stdin);
- scanf("%c",&punteroApaciente->sexo);//super valida!!!
- }
- paciente cargarPaciente()
- {
- paciente pacienteLocal;
- //scanf("%????",&paciente1); invalida
- printf("numeroExpediente\n");
- fflush(stdin);
- scanf("%d",&pacienteLocal.numeroExpediente);//super valida!!!
- printf("nombre\n");
- fflush(stdin);
- scanf("%s",&pacienteLocal.nombre);//super valida!!!
- printf("sexo\n");
- fflush(stdin);
- scanf("%c",&pacienteLocal.sexo);//super valida!!!
- int indiceCuotas;
- for (indiceCuotas=0;indiceCuotas<3;indiceCuotas++)
- {
- printf("ingrese cuota %d\n",indiceCuotas+1);
- fflush(stdin);
- scanf("%f",&pacienteLocal.cuotas[indiceCuotas]);
- }
- return pacienteLocal;
- }
- void mostrarPaciente(paciente pacAux)
- {
- printf("%d\n",pacAux.numeroExpediente);
- printf("%s\n",pacAux.nombre);
- printf("%c\n",pacAux.sexo);
- int indiceCuotas;
- for (indiceCuotas=0;indiceCuotas<3;indiceCuotas++)
- {
- printf("cuota %d -> $ %f\n",indiceCuotas+1,pacAux.cuotas[indiceCuotas]);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement