Ir ao conteúdo
  • Cadastre-se

busca e consulta


Posts recomendados

bom eu sou novo em programação, estou começando agora, e estou tendo problemas com a busca, listagem e cadastro de notas em meu sistema, o código compilar porém na execução,

1-para, encerra a execução na listagem por media;

2-na consulta individual, só encontra o primeiro registro;

3- no cadastro de notas ele cadastro porém não armazena os valores...

agradeço desde já!!!!

 

segue o anexo

 

 

 

aqui o codigo:

 

// MAIN

#include <stdio.h>
#include <stdlib.h>
#include "biblio.h"
 
 
int main()
{
int opc;
nota n={NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL};
do{
    system("cls");
 
     menuprincipal();
     scanf("%d",&opc);
     setbuf(stdin,NULL);
 
    switch(opc){
 
            case 1:
                system("cls");
                cadastra(&n);
                break;
            case 2:
                system("cls");
                consulta(&n);
                 break;
            case 3:
                system("cls");
                cadastranotas(&n);
                break;
            case 4:
                system("cls");
                listadealunos(&n);
                break;
            case 5:
                printf("FINALIZANDO O SISTEMA DE CADASTRO DE ALUNO");
                break;
            default:
                printf("\n\nDESCULPE, ESSA OPCAO NAO EXISTE!!!");
                break;
    }}while(opc!=5);
 
    return 0;
}
 
 
//FUNCOES
 
#include<stdio.h>
#include<string.h>
#include "biblio.h"
 
 
    void menuprincipal(void){
        printf("|==============================================================================|");
        printf("\n\n\t\t      ***** SISTEMA DE CADASTRO DE ALUNOS *****    \t\t\n\n");
        printf("|==============================================================================|");
        printf("\t\t\t\t-1- CADASTRAR ALUNO***\n\n");
        printf("|\n\t\t\t  -2- CONSULTA DADOS DE UM ALUNO***\n\n");
        printf("|\n\t\t\t\t-3- CADASTRAR NOTAS***\n\n");
        printf("|\n\t\t\t\t-4- MODOS DE LISTAR'***\n\n");
        printf("|\n\t\t\t\t-5- SAIR DO CADASTRO***\n\n");
        printf("\n FACA UMA ESCOLHA:--> ");
}
 
    void menulistar(void){
        printf("\n\n\t\t\t***** TIPOS DE LISTAGEM *****\n\n");
        printf("\n-1- LISTAR POR ORDEM DE CASDATRO***\n\n");
        printf("\n-2- LISTAR POR MEDIA***\n\n");
        printf("\n-3- SAIR DA LISTAGEM***\n\n");
        printf("\n\n FACA UMA ESCOLHA:-->");
}
    void menulistarordem(void){
        printf("\n\n\t\t\t***** LISTAGEM  POR ORDEM DE CADASTRO*****\n\n");
        printf("\n-1- LISTAR TODOS***\n\n");
        printf("\n-2- LISTAR EM ORDEM CRESCENTE DE CADASTRO***\n\n");
        printf("\n-3- LISTAR EM ORDEM DESCRESCRENTE DE CADASTRO***\n\n");
        printf("\n-4- SAIR DA LISTAGEM***\n\n");
        printf("\n\n FACA UMA ESCOLHA:--> ");
}
    void menulistarmedia(void){
        printf("\n\n\t\t\t***** LISTAGEM POR MEDIA *****\n\n");
        printf("\n-1- LISTAR ALUNOS A CIMA DA MEDIA***\n\n");
        printf("\n-2- LISTAR ALUNOS A BAIXO DA MEDIA***\n\n");
        printf("\n-3- LISTAR EM ORDEM CRESCENTE DE MEDIA***\n\n");
        printf("\n-4- LISTAR EM ORDEM DESCRESCRENTE DE MEDIMA***\n\n");
        printf("\n-5- SAIR DA LISTAGEM***\n\n");
        printf("\n\n FACA UMA ESCOLHA:--> ");
}
int semaluno(nota *p){
    int i;
    for(i=0;i<10;i++)if(p->vet.nome==NULL){
        return 1;
    }
 else return 0;
}
 
void cadastra(nota *p){
    int i; // INDICE (VARIAVEL DE CONTROLE
         for(i=0;i<10;i++){
                if(semaluno(&p)==0){
                   printf("\n|==============================================================================|\n\n");
                   printf("\t\t\t\tCADASTRO DE ALUNOS!!");
                   printf("\n\n|==============================================================================|");
                   printf("\nALUNO [%d]\n\n",i+1);
                   fflush(stdin);
                   printf("NOME: ");
                   gets(p->vet.nome);
                   printf("\n\t\t\tnOBS: a matricula deve conter -> \n\t\t Ano+iniciais curso+iniciais do nome do aluno!");
                   printf("\nMATRICULA DO ALUNO: ");
                   gets(p->vet.matricula);
                   printf("\nIDADE: ");
                   scanf("%d", &p->vet.idade);
                   fflush(stdin);
                   printf("\nENDERECO: ");
                   gets(p->vet.endereco);
                   printf("\nTELEFONE: ");
                   scanf("%d", &p->vet.telefone);
                  system("cls");
                 }
                 else
                    printf("NAO E POSSIVEL CADASTRAR");
         }
};
        //CONSULTANDO DADOS DE UM ÚNICO ALUNDO
void consulta(nota *p){
            char tempnome[35], tempmatricula[20];
            int i,opc;
            do{
                system("cls");
                printf("\n|==============================================================================|\n\n");
                printf("   \t DESEJA CONSULTAR DADOS DO ALUNO POR NOME OU MATRICULA?");
                printf("\n\n|==============================================================================|");
                printf("\n-1- NOME***\n\n");
                printf("\n-2- MATRICULA***\n\n");
                printf("\n-3- SAIR DA CONSULTA DO ALUNO***\n\n");
                printf("\n\n FACA UMA ESCOLHA:--> ");
                fflush(stdin);
                scanf("%d",&opc);
 
                    switch(opc){
                    case 1:
                    fflush(stdin);
                    printf("\n\n\t\t\t\tNOME: ");
                    gets(tempnome);
                    printf("\t\t\t\tAluno: [%s]\n\n",tempnome);
                    system("pause");
 
                        for (i=0;i<10;i++){
                        if (strcmp(tempnome,p->vet.nome)==1){
                               printf("\n|==============================================================================|\n\n");
                               printf("\t\t\tLISTAGEM - PELO NOME DO ALUNO!!");
                               printf("\n\n|==============================================================================|");
                               printf("\nALUNO [%d]\n\n",i+1);
                               printf("NOME:%s ",p->vet.nome);
                               printf("\nMATRICULA DO ALUNO: %s",p->vet.matricula);
                               printf("\nIDADE: %d",p->vet.idade);
                               printf("\nENDERECO: %s",p->vet.endereco);
                               printf("\nTELEFONE: %d", p->vet.telefone);
                               printf("\n\n--------------------------------------------------------------------------------");
                               system("pause");
                               break;
                               }
                                    if(strcmp(tempnome,p->vet.nome)!=0){
                                        printf("\nNOME NAO ENCONTRADO !!!");
                                        system("pause");
                                       } break;
 
                }
                       break;
                  case 2:
                    fflush(stdin);
                    printf("\n\n\t\t\t\tMATRICULA: ");
                    gets(tempmatricula);
                    printf("\t\t\t\tAluno: [%s]\n\n",tempmatricula);
                    system("pause");
                    for(i=0;i<10;i++){
                        if(strcmp(tempmatricula,p->vet.matricula)==0){
                           printf("\n|==============================================================================|\n\n");
                           printf("\t\t\tLISTAGEM - PELA MATRICULA DO ALUNO !!");
                           printf("\n\n|==============================================================================|");
                               printf("\nALUNO [%d]\n\n",i+1);
                               printf("NOME:%s ",p->vet.nome);
                               printf("\nMATRICULA DO ALUNO: %s",p->vet.matricula);
                               printf("\nIDADE: %d",p->vet.idade);
                               printf("\nENDERECO: %s",p->vet.endereco);
                               printf("\nTELEFONE: %d", p->vet.telefone);
                               printf("\n\n--------------------------------------------------------------------------------");
                               system("pause");
                     }
 
                                    if(strcmp(tempmatricula,p->vet.matricula)!=0){
                                    printf("\nMATRICULA NAO ENCONTRADA !!!");
                                    system("pause");
                                   }break;
                }
 
                       break;
 
                  case 3:
                       printf("ENCERRANDO A BUSCA INDIVIDUAL DE ALUNO....");
 
                  default:
                    printf("\n\nA OPCAO DIGITADA NAO EXISTE!!!");
                    system("pause");
            }
}while(opc!=3);
 
}
     //CADASTRAR NOTAS DO ALUNO
 void cadastranotas(nota *p){
            char tempnome[35];
            int i, i2;
            printf("\n|==============================================================================|\n\n");
            printf("\t\t PARA QUAL ALUNO DESEJA ATRIBUIR AS NOTAS? !!");
            printf("\n\n|==============================================================================|");
           fflush(stdin);
            printf("\n\t\t\tNOME DO ALUNO: ");
            gets(tempnome);
 
            for(i=0;i<10;i++){
                if(strcmp(tempnome,p->vet.nome)==0){
                    for(i2=0;i2<3;i2++){
                       printf("[%d'] - NOTA : ",i+1);
                       scanf("%d", &p->vet.notaa[i2].notas);
                    };
                }
            }
 
              printf("\nMEDIA DO ALUNO: %d",p->vet.media);
              printf("nota 1: \n%d Nota 2: %d \nnota 3: %d",p->vet.notaa[0].notas,p->vet.notaa[1].notas,p->vet.notaa[2].notas);
              system("pause");
        }
 
 
        //VERIFICA ALUNOS ACIMA DA MEDIA
void acmedia(nota *p){
           int i;
           printf("\n|==============================================================================|\n\n");
           printf("\t\t\t\tLISTAGEM - ALUNOS A CIMA DA MEDIA !!");
           printf("\n\n|==============================================================================|");
           for(i;i<10;i++){
           if (p->vet.media>7){
                    printf("NOME:%s ",p->vet.nome);
                    printf("\nMATRICULA DO ALUNO: %s",p->vet.matricula);
                    printf("\nIDADE: %d",p->vet.idade);
                    printf("\nENDERECO: %s",p->vet.endereco);
                    printf("\nTELEFONE: %d", p->vet.telefone);
                    printf("\nMEDIA DO ALUNO: ",p->vet.media);
                    printf("\n\n--------------------------------------------------------------------------------");
              }
       }
}
void mdbaixa(nota *p){
           int i;
           printf("\n|==============================================================================|\n\n");
           printf("\t\t\t\tLISTAGEM - ALUNOS A BAIXO DA MEDIA !!");
           printf("\n\n|==============================================================================|");
           for(i;i<10;i++){
           if (p->vet.media<7){
                    printf("NOME:%s ",p->vet.nome);
                    printf("\nMATRICULA DO ALUNO: %s",p->vet.matricula);
                    printf("\nIDADE: %d",p->vet.idade);
                    printf("\nENDERECO: %s",p->vet.endereco);
                    printf("\nTELEFONE: %d", p->vet.telefone);
                    printf("\nMEDIA DO ALUNO: ",p->vet.media);
                    printf("\n\n--------------------------------------------------------------------------------");
              }
       }
}
         // ORGANIZA EM ORDEM CRESCENTE
void mediacrescente(nota *p){
        struct recebedados{
          char tnom[35],tmat[20],tende[50];
          int tidad,ttel,tnotage;
        }tdado[10];
 
           char nom, mat, ende;
           int idad,tel,notag,i,j;
             system("cls");
              for(i=0;i<9;i++){
                strcpy(tdado.tnom,p->vet.nome);
                strcpy(tdado.tmat,p->vet.matricula);
                strcpy(tdado.tende,p->vet.endereco);
                tdado.tidad=p->vet.idade;
                tdado.ttel=p->vet.telefone;
                tdado.tnotage=p->vet.notageral;
        }
 
 
                    for(i=0;i<9;i++){
                       for(j=i+1;j<10;j++){
                          if(tdado.tnotage>tdado[j].tnotage){
                                //DANDO VALOR DA MAIOR MEDIA A VARIAVEL DE TROCA
                                strcpy(nom,tdado.tnom);
                                strcpy(mat,tdado.tmat);
                                strcpy(ende,tdado.tende);
                                idad= tdado.tidad;
                                tel= tdado.ttel;
                                notag= tdado.tnotage;
 
                                //ATRIBUINDO OS VALRES DE MENOR POSIÇÃO AO INICIO
                                strcpy(tdado.tnom,tdado[j].tnom);
                                strcpy(tdado.tmat,tdado[j].tmat);
                                strcpy(tdado.tende,tdado[j].tende);
                                tdado.tidad= tdado[j].tidad;
                                tdado.ttel= tdado[j].ttel;
                                tdado.tnotage= tdado[j].tnotage;
 
                                // A INICIALMENTE MENOR RECEBE VALORES DE QUEM ERA MAIOR
                                strcpy(tdado[j].tnom,nom);
                                strcpy(tdado[j].tmat,mat);
                                strcpy(tdado[j].tende,ende);
                                tdado[j].tidad=idad;
                                tdado[j].ttel= tel;
                                tdado[j].tnotage= notag;
                          }
                      }
                }
 
                   printf("\n|==============================================================================|\n\n");
                   printf("\t\t\t\tLISTAGEM - ALUNOS EM ORDEM CRESCENTE DE MEDIA !!");
                   printf("\n\n|==============================================================================|");
                     for(i=0;i<10;i++){
                       printf("\nALUNO [%d]\n\n",i+1);
                       printf("NOME:%s ",tdado.tnom);
                       printf("\nMATRICULA DO ALUNO: %s",tdado.tmat);
                       printf("\nIDADE: %d",tdado.tidad);
                       printf("\nENDERECO: %s",tdado.tende);
                       printf("\nTELEFONE: %d", tdado.ttel);
                       printf("\nMEDIA DO ALUNO: ",tdado.tnotage);
                       printf("\n\n--------------------------------------------------------------------------------");
          }
}
         // ORGANIZA EM ORDEM CRESCENTE
void mediadecrescente(nota *p){
        struct recebedados{
          char tnom[35],tmat[20],tende[50];
          int tidad,ttel,tnotage;
        }tdado[10];
 
           char nom, mat, ende;
           int idad,tel,notag,i,j;
 
              for(i=0;i<9;i++){
                strcpy(tdado.tnom,p->vet.nome);
                strcpy(tdado.tmat,p->vet.matricula);
                strcpy(tdado.tende,p->vet.endereco);
                tdado.tidad= p->vet.idade;
                tdado.ttel= p->vet.telefone;
                tdado.tnotage= p->vet.notageral;
        }
 
 
                    for(i=0;i<9;i++){
                       for(j=i+1;j<10;j++){
                          if(tdado.tnotage<tdado[j].tnotage){
                                //DANDO VALOR DA MENOR MEDIA A VARIAVEL DE TROCA
                                strcpy(nom,tdado.tnom);
                                strcpy(mat,tdado.tmat);
                                strcpy(ende,tdado.tende);
                                idad= tdado.tidad;
                                tel= tdado.ttel;
                                notag= tdado.tnotage;
 
                                //ATRIBUINDO OS VALRES DE MENOR POSIÇÃO AO INICIO
                                strcpy(tdado.tnom,tdado[j].tnom);
                                strcpy(tdado.tmat,tdado[j].tmat);
                                strcpy(tdado.tende,tdado[j].tende);
                                tdado.tidad= tdado[j].tidad;
                                tdado.ttel= tdado[j].ttel;
                                tdado.tnotage= tdado[j].tnotage;
 
                                // A INICIALMENTE MENOR RECEBE VALORES DE QUEM ERA MAIOR
                                strcpy(tdado[j].tnom,nom);
                                strcpy(tdado[j].tmat,mat);
                                strcpy(tdado[j].tende,ende);
                                tdado[j].tidad=idad;
                                tdado[j].ttel= tel;
                                tdado[j].tnotage=notag;
                          }
                      }
                }
 
                   printf("\n|==============================================================================|\n\n");
                   printf("\t\t\t\tLISTAGEM - ALUNOS EM ORDEM DECRESCENTE DE MEDIA !!");
                   printf("\n\n|==============================================================================|");
                     for(i=0;i<10;i++){
                       printf("\nALUNO [%d]\n\n",i+1);
                       printf("NOME:%s ",tdado.tnom);
                       printf("\nMATRICULA DO ALUNO: %s",tdado.tmat);
                       printf("\nIDADE: %d",tdado.tidad);
                       printf("\nENDERECO: %s",tdado.tende);
                       printf("\nTELEFONE: %d", tdado.ttel);
                       printf("\nMEDIA DO ALUNO: ",tdado.tnotage);
                       printf("\n\n--------------------------------------------------------------------------------");
          }
}
          // TIPOS DE LISTAGEM
 void listadealunos(nota *p){
       int i,oplc,opc1,opc2; // INDICE (VARIAVEL DE CONTROLE,OPÇÃO DO MENU
       nota t; // variavel da struct
 
       do{
           system("cls");
           menulistar();
           scanf("%d",&oplc);
           switch(oplc){
                case 1:
                    do{
                    system("cls");
                    menulistarordem();
                    scanf("%d",&opc1);
                    setbuf(stdin,NULL);
 
                        switch(opc1){
                        case 1:
                            system("cls");
                               printf("\n|==============================================================================|\n\n");
                               printf("\t\t\t\tLISTAGEM - TODOS OS ALUNOS !!");
                               printf("\n\n|==============================================================================|");
                                 for(i=0;i<10;i++){
                                   printf("\nALUNO [%d]\n\n",i+1);
                                   printf("NOME:%s ",p->vet.nome);
                                   printf("\nMATRICULA DO ALUNO: %s",p->vet.matricula);
                                   printf("\nIDADE: %d",p->vet.idade);
                                   printf("\nENDERECO: %s",p->vet.endereco);
                                   printf("\nTELEFONE: %d", p->vet.telefone);
                                   printf("\n\n--------------------------------------------------------------------------------");
                                 }
                                  system("pause");
                            break;
                        case 2:
                            system("cls");
                               printf("\n|==============================================================================|\n\n");
                               printf("\t\t\t\tLISTAGEM - CRESCENTE DE CASDASTRO !!");
                               printf("\n\n|==============================================================================|");
                                 for(i=0;i<10;i++){
                                   printf("\nALUNO [%d]\n\n",i+1);
                                   printf("NOME:%s ",p->vet.nome);
                                   printf("\nMATRICULA DO ALUNO: %s",p->vet.matricula);
                                   printf("\nIDADE: %d",p->vet.idade);
                                   printf("\nENDERECO: %s",p->vet.endereco);
                                   printf("\nTELEFONE: %d", p->vet.telefone);
                                   printf("\n\n--------------------------------------------------------------------------------");
                                 }
                                  system("pause");
                            break;
                        case 3:
                            system("cls");
                               printf("\n|==============================================================================|\n\n");
                               printf("\t\t\tLISTAGEM - EM ORDEM DESCRESCENTE DE CADASTRO !!");
                               printf("\n\n|==============================================================================|");
                                 for(i=9;i>=0;i--){
                                   printf("\nALUNO [%d]\n\n",i+1);
                                   printf("NOME:%s ",p->vet.nome);
                                   printf("\nMATRICULA DO ALUNO: %s",p->vet.matricula);
                                   printf("\nIDADE: %d",p->vet.idade);
                                   printf("\nENDERECO: %s",p->vet.endereco);
                                   printf("\nTELEFONE: %d", p->vet.telefone);
                                   printf("\n\n--------------------------------------------------------------------------------");
                                 }
                                  system("pause");
                            break;
                        case 4:
                            printf("FINALIZANDO A LISTAGEM POR ORDEM\n");
                            break;
                        default:
 
                            system("pause");
                            break;
                        }
 
                    }while(opc1!=4);
                    break;
                case 2:
                    //LISTAGEM POR MEDIA
                   do{
                    system("cls");
                    menulistarmedia();
                    scanf("%d",&opc2);
                    setbuf(stdin,NULL);
 
                        switch(opc2){
                        case 1:
                            system("cls");
                            acmedia(&t);
                            break;
                        case 2:
                            system("cls");
                            mdbaixa(&t);
                            break;
                        case 3:
                            system("cls");
                            mediacrescente(&t);
                            break;
                        case 4:
                            system("cls");
                            mediadecrescente(&t);
                            break;
                        case 5:
                            printf("FINALIZANDO A LISTAGEM POR MEDIA");
                            break;
                        default:
                            printf("\n\nDESCULPE, A OPCAO DIGITADA NAO EXISTE!!!");
                            break;
                        }
                    }while(opc2!=5);
                    break;
                case 3:
                    printf("FINALIZANDO AS LISTAGENS");
 
                default:
                    printf("\n\nDESCULPE, A OPCAO DIGITADA NAO EXISTE!!!");
                    break;
           }
     }while(oplc!=3);
 
 }
 
//BIBLIOTECA
 
typedef struct CAluno{
    char nome[35], matricula[20], endereco[50];
    int idade, telefone,notageral;
    float media;
            struct bnotas{
             int notas;
            }notaa[3];
 
}aluno;
 
typedef struct notaaluno{
    aluno vet[10];
}nota;
        // POTÓTIPOS DAS MINHAS FUNÇÕES
 
    void cadastra(nota *p);/// cadastrar aluno
    void consulta(nota *p);  /// consultar dados dos alunos
    void mdbaixa(nota *p); /// mostrar alunos a baixo da media
    void acmedia(nota *p);   ///mostrar alunos acima da media
    void listadealunos(nota *p); /// mostrar lista de todos os alunos ( ordem crescente, descrescente, todos)
    void cadastranotas(nota *p); /// cadastro das notas do aluno "x"
    void mediacrescente(nota *p); /// lista em ordem crescente
    void mediadecrescente(nota *p); /// lista em ordem decrescente
    void crescente(nota *p); ///lista em ordem crescente
    void decrescente(nota *p);   /// lista em ordem decrescente de castro
    int semaluno(nota *p);
 

 

Link para o comentário
Compartilhar em outros sites

  • mês depois...
Visitante
Este tópico está impedido de receber novas respostas.

Sobre o Clube do Hardware

No ar desde 1996, o Clube do Hardware é uma das maiores, mais antigas e mais respeitadas comunidades sobre tecnologia do Brasil. Leia mais

Direitos autorais

Não permitimos a cópia ou reprodução do conteúdo do nosso site, fórum, newsletters e redes sociais, mesmo citando-se a fonte. Leia mais

×
×
  • Criar novo...