Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- typedef struct{
- int matricula;
- char nome[30];
- char CPF[11];
- int AnoIngresso;
- }CADASTRO;
- struct notas{
- float primeira;
- float segunda;
- float terceira;
- float final;
- }NOTAS;
- typedef struct{
- int matricula;
- char disciplina[40];
- struct notas notas;
- char aprovado[3];
- }DISCIPLINAS;
- typedef struct{
- int matricula;
- float debito;
- int DisciplinasRestantes;
- }SITUACAO;
- typedef struct{
- int matricula;
- float debito;
- }RELATORIO;
- void preenche(FILE *arquivo1, FILE *arquivo2, FILE *arquivo3, FILE *arquivo4){
- do{
- int x=1;
- CADASTRO *cadastro;
- DISCIPLINAS *disciplinas;
- SITUACAO *situacao;
- RELATORIO *relatorio;
- fread(cadastro,sizeof(CADASTRO),x,arquivo1);
- if(cadastro->AnoIngresso == 2011){
- do{
- int y = 1;
- fread(disciplinas,sizeof(DISCIPLINAS),y,arquivo2);
- if(strcmp(disciplinas->aprovado,"sim")==0){
- do{
- int z = 1;
- fread(situacao,sizeof(SITUACAO),z,arquivo3);
- if(situacao->debito != 0){
- relatorio->matricula = cadastro->matricula;
- relatorio->debito = situacao->debito;
- fwrite(relatorio,sizeof(RELATORIO),1,arquivo4);
- z++;
- }while(feof(arquivo3));
- y++;
- }else{
- printf("Esse aluno não foi ingressado em 2011");
- }
- }while(feof(arquivo2));
- x++;
- }else{
- printf("Não há alunos ingressados em 2011 aprovados");
- }
- }
- }else{
- printf("Não há alunos ingressados em 2011");
- }
- }while(feof(arquivo1));
- }
- int main(){
- FILE *cadastroCad;
- cadastroCad = fopen("Cadastro.cad", "r+b");
- FILE *disciplinasCad;
- disciplinasCad = fopen("Disciplinas.cad", "r+b");
- FILE *situacaoCad;
- situacaoCad = fopen("Situacao.cad", "r+b");
- FILE *relatorioCad;
- relatorioCad = fopen("Relatorio.cad", "r+b");
- preenche(cadastroCad,disciplinasCad, situacaoCad,relatorioCad);
- getche(0);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement