TrabalhosGratuitos.com - Trabalhos, Monografias, Artigos, Exames, Resumos de livros, Dissertações
Pesquisar

Cadastro Voo

Trabalho Escolar: Cadastro Voo. Pesquise 860.000+ trabalhos acadêmicos

Por:   •  6/10/2014  •  1.581 Palavras (7 Páginas)  •  228 Visualizações

Página 1 de 7

#include <stdio.h>

#include <stdlib.h>

#include <iostream>

#include <cstdlib>

#include <conio.h>

#include <locale.h>

struct voo

{

int numvoo;

char datavoo[30];

char horavoo[30];

char saidavoo[50];

char chegadavoo[50];

char rota[30];

int tempovoo;

int passageirosvoo;

int opcao;

int valor;

struct voo *prox;

};

struct voo x,*aux, *inicio = NULL, *final = NULL;

struct voo* cria(void) //função responsável por criar a lista

{

return NULL;

}

struct voo* insere_final() //função com tipo de retorno ponteiro para estrutura, realizando inserção pelo final

{

system("cls");

printf("----------------CADASTRO DE VOO------------------\n\n");

printf("DIGITE A DATA DO VOO: ");

getchar();

gets(x.datavoo);

printf("DIGITE O HORÁRIO DO VOO: ");

getchar();

gets(x.horavoo);

printf("DIGITE O AEROPOSTO DE SAÍDA DO VOO: ");

getchar();

gets(x.saidavoo);

printf("DIGITE O AEROPORTO DE CHEGADA DO VOO: ");

getchar();

gets(x.chegadavoo);

printf("DIGITE A ROTA DO VOO: ");

getchar();

gets(x.rota);

printf("DIGITE O TEMPO DO VOO: ");

scanf("%i",&x.tempovoo);

printf("DIGITE A QUANTIDADE DE PASSAGEIROS DO VOO: ");

scanf("%i",&x.passageirosvoo);

printf("DIGITE O NÚMERO DO VOO: ");

scanf("%i",&x.numvoo);

aux = (struct voo*) malloc (sizeof(struct voo));

aux->valor = x.numvoo;

aux -> prox = (struct voo *) NULL;

if(inicio == NULL)

inicio = final = aux;

else

{

final -> prox = aux;

final = aux;

}

return inicio;

}

int lista_vazia(struct voo *lista) //função que verifica o estado da lista: retorno 1 se vazia ou 0 se não vazia

{

if(lista == NULL)

return 1;

else

return 0;

}

struct voo* busca(struct voo* lista, int busca) //função que busca um elemento na lista

{

bool achou = 0;

if(!lista_vazia(lista))

{

for(aux=lista;aux!=NULL;aux=aux->prox)

{

if(aux->valor == busca)

{

system("cls");

printf("----------------CADASTRO DE VOO------------------\n\n");

printf("\nNÚMERO DO VOO: %d\n",busca);

printf("QUANTIDADE DE PASSAGEIROS: %d\n",x.passageirosvoo);

printf("AEROPOSTO DE SAÍDA: %s\n",x.saidavoo);

printf("AEROPORTO DE CHEGADA: %s\n",x.chegadavoo);

printf("DATA: %s\n",x.datavoo);

printf("ROTA: %s\n",x.rota);

printf("TEMPO: %d\n",x.tempovoo);

printf("HORÁRIO: %s\n",x.horavoo);

achou = 1;

}

}

if(!achou)

...

Baixar como (para membros premium)  txt (5 Kb)  
Continuar por mais 6 páginas »
Disponível apenas no TrabalhosGratuitos.com