Exemplo n.º 1
0
int main()
{
	int opcao;
	int sequencia = 0;
	TPilha pilha_alunos;
	TFila fila_notas;
	pilha_alunos.topo = -1;
	fila_notas.tamanho_fila = 0;

	do{
		menu();
		scanf("%d",&opcao);
		switch(opcao){
			case 0: ExibeListas(&pilha_alunos);break;
			case 1: CadastraAluno(&pilha_alunos,&sequencia);break;
			case 2: InsereNotas(&pilha_alunos,&fila_notas);break;
			case 3: CalculaMedia(&pilha_alunos,&fila_notas);break;
			case 4: AlunosSemNotas(&pilha_alunos,&fila_notas);break;
			case 5: ExcluiAluno(&pilha_alunos,&fila_notas);break;
			case 6: ExcluiNota(&pilha_alunos,&fila_notas);break;
			case 8: ExibeListasNotas(&pilha_alunos,&fila_notas);break;
			case 7: break;
		}
	}while(opcao != 7);
}
main(){

    struct aluno *inicio;
    inicio = NULL;

    struct aluno *aluno;
    aluno = NULL;

    int tecla = -1;

    int codigoAluno = 0;
    char nome[50];
    int codigoLivro = 0;
    char titulo[30];

    while(1)
    {
        system("clear");

        MostraAlunos(inicio);

        printf("\n\n\n0 - Para Sair");
        printf("\n1 - Incluir Novo Aluno");
        printf("\n2 - Para Selecionar um Aluno");
        printf("\n3 - Mostrar Alunos e Livros");

        tecla = -1;
        printf("\n\nTecla: ");
        scanf("%d", &tecla);

        if(tecla == 0)
            break;
        else if(tecla == 1)
        {
            printf("\nCodigo: ");
            scanf("%d", &codigoAluno);

            printf("\nNome: ");
            scanf("%s", &nome);
            getchar();

            inicio = IncluiAlunoOrdenado(inicio, codigoAluno, nome);
        }
        else if(tecla == 2)
        {
            printf("\nCodigo do Aluno: ");
            scanf("%d", &codigoAluno);

            aluno = PegaAluno(inicio, codigoAluno);

            if(aluno == NULL)
                continue;

            while(1)
            {
                system("clear");

                MostraAluno(aluno);
                printf("\n\n");
                MostraLivros(aluno->reservas);

                printf("\n\n\n0 - Para Voltar");
                printf("\n1 - Para Exluir o Aluno");
                printf("\n2 - Para Incluir um Novo Livro");
                printf("\n3 - Para Excluir um Livro");

                tecla = -1;
                printf("\n\nTecla: ");
                scanf("%d", &tecla);

                if(tecla == 0)
                    break;
                else if(tecla == 1)
                {
                    inicio = ExcluiAluno(inicio, codigoAluno);
                    break;
                }
                else if(tecla == 2)
                {
                    printf("\nCodigo: ");
                    scanf("%d", &codigoLivro);
                    printf("\nTitulo: ");
                    scanf("%s", &titulo);
                    getchar();
                    aluno->reservas = IncluiLivroOrdenado(aluno->reservas, codigoLivro, titulo);
                }
                else if(tecla == 3)
                {
                    printf("\nCodigo: ");
                    scanf("%d", &codigoLivro);
                    aluno->reservas = ExcluiLivro(aluno->reservas, codigoLivro);
                }
                else
                    continue;

                getchar();
            }
        }
        else if(tecla == 3)
        {
            system("clear");
        	MostraTudo(inicio);
        	getchar();
        }
        else
            continue;

        getchar();
    }

    getchar();
};