Advertisement
ThaisAlmeida

2012.2 - questão 1

Jul 27th, 2014
199
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.19 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. typedef struct{
  5.     int matricula;
  6.     char nome[30];
  7.     char CPF[11];
  8.     int AnoIngresso;
  9. }CADASTRO;
  10.  
  11. struct notas{
  12.     float primeira;
  13.     float segunda;
  14.     float terceira;
  15.     float final;
  16. }NOTAS;
  17.  
  18. typedef struct{
  19.     int matricula;
  20.     char disciplina[40];
  21.     struct notas notas;
  22.     char aprovado[3];
  23.     }DISCIPLINAS;
  24.  
  25. typedef struct{
  26.     int matricula;
  27.     float debito;
  28.     int DisciplinasRestantes;
  29.     }SITUACAO;
  30.  
  31. typedef struct{
  32.     int matricula;
  33.     float debito;
  34.     }RELATORIO;
  35.  
  36.  
  37. void preenche(FILE *arquivo1, FILE *arquivo2, FILE *arquivo3, FILE *arquivo4){
  38. do{
  39.     int x=1;
  40.     CADASTRO *cadastro;
  41.     DISCIPLINAS *disciplinas;
  42.     SITUACAO *situacao;
  43.     RELATORIO *relatorio;
  44.  
  45.     fread(cadastro,sizeof(CADASTRO),x,arquivo1);
  46.     if(cadastro->AnoIngresso == 2011){
  47.  
  48.         do{
  49.             int y = 1;
  50.             fread(disciplinas,sizeof(DISCIPLINAS),y,arquivo2);
  51.             if(strcmp(disciplinas->aprovado,"sim")==0){
  52.  
  53.                 do{
  54.                 int z = 1;
  55.                 fread(situacao,sizeof(SITUACAO),z,arquivo3);
  56.                 if(situacao->debito != 0){
  57.                 relatorio->matricula = cadastro->matricula;
  58.                 relatorio->debito = situacao->debito;
  59.                 fwrite(relatorio,sizeof(RELATORIO),1,arquivo4);
  60.  
  61.                 z++;
  62.  
  63.                 }while(feof(arquivo3));
  64.             y++;
  65.         }else{
  66.                 printf("Esse aluno não foi ingressado em 2011");
  67.             }
  68.             }while(feof(arquivo2));
  69. x++;
  70.  
  71.  
  72.         }else{
  73.             printf("Não há alunos ingressados em 2011 aprovados");
  74.         }
  75.         }
  76.         }else{
  77.          printf("Não há alunos ingressados em 2011");
  78.          }
  79.     }while(feof(arquivo1));
  80.     }
  81.  
  82. int main(){
  83.     FILE *cadastroCad;
  84.     cadastroCad = fopen("Cadastro.cad", "r+b");
  85.     FILE *disciplinasCad;
  86.     disciplinasCad = fopen("Disciplinas.cad", "r+b");
  87.     FILE *situacaoCad;
  88.     situacaoCad = fopen("Situacao.cad", "r+b");
  89.     FILE *relatorioCad;
  90.     relatorioCad = fopen("Relatorio.cad", "r+b");
  91.  
  92.     preenche(cadastroCad,disciplinasCad, situacaoCad,relatorioCad);
  93.  
  94.     getche(0);
  95. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement