Advertisement
Guest User

Untitled

a guest
May 29th, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 3.16 KB | None | 0 0
  1.  
  2. void increver_aluno(List_aluno_node *headaluno,List_exame_node *headexame){ /*introduzir as epocas*/
  3.  List_aluno_node temp,tempa;
  4.  List_exame_node temp1,conta;
  5.  List_salas se;
  6.  ListApontAlunos headah;
  7.  ListApontExames headeh;
  8.  List_salas salas;
  9.  salas=malloc(sizeof(Salas_exame));
  10.  int inscritos=0,nexames=0,flag=1;
  11.  headeh=malloc(sizeof(NoApontExames));
  12.  headah=malloc(sizeof(NoApontAluno));
  13.  int i=0,num,n;
  14.  char exam[100];
  15.  if(*headaluno==NULL){
  16.     printf("Não ha alunos inscritos\n");
  17.     return;
  18.  }
  19.  if(*headexame==NULL){
  20.     printf("Não ha exames criados\n");
  21.     return;
  22.  }
  23.  printf("Qual o numero do aluno que pretende inscrever?\n");
  24.  scanf("%d",&num);
  25.  temp=*headaluno;
  26.  while((temp->numero)!=num){
  27.    temp=temp->next;
  28.    if((temp->next==NULL) && (temp->numero!=num)){
  29.      printf("O numero nao existe\n");
  30.    }
  31.  }
  32.  headah->aluno=temp;
  33.  headah->next=NULL;
  34.  tempa=temp;
  35.  fflush(stdin);
  36.  printf("Qual o exame em que pretende inscrever o aluno?\n");
  37.  fgets(exam,100,stdin);
  38.  printf("Qual a epoca?");
  39.  scanf("%d",&n);
  40. temp1=*headexame;
  41.  while(strcmp((temp1->disciplina)->nome,exam)!=0 && (temp1->epoca!=n)){
  42.    temp1=temp1->next;
  43.    if((temp1->next==NULL) && (strcmp((temp1->disciplina)->nome,exam))!=0 && (temp1->epoca!=n)){
  44.      printf("O exame nao existe\n");
  45.    }
  46.  }
  47.   headeh->exame=temp1;
  48.   headeh->next=NULL;
  49.  if((temp->regime==1)&&(temp1->epoca==3)){
  50.     printf("Nao pode inscrever o aluno nessa fase\n");
  51.     return;
  52.  }
  53.  else{
  54.     if((temp->exames)==NULL){
  55.         temp->exames=headeh;
  56.         temp->nexames=1;
  57.     }
  58.     else{
  59.         while((temp->exames)!=NULL){
  60.             temp->exames=temp->exames->next;
  61.             nexames++;
  62.         }
  63.         nexames++;
  64.         temp->nexames=nexames;
  65.         temp->exames=headeh;
  66.  }
  67.     if((temp1->alunos)==NULL){
  68.         temp1->alunos=headah;
  69.         temp1->inscritos=1;
  70.     }
  71.     else{
  72.         while((temp1->alunos)!=NULL){
  73.             temp1->alunos=temp1->alunos->next;
  74.             inscritos++;
  75.         }
  76.         inscritos++;
  77.         temp1->alunos=headah;
  78.         temp1->inscritos=inscritos;
  79.  }
  80.  }
  81.  salas=temp1->ssala;
  82.  
  83.  int contador=0;
  84.  if((temp1->inscritos%30 != 0) && (temp1->inscritos >30)){
  85.     int auxiliar = temp1->inscritos;
  86.     auxiliar-=30;
  87.     contador++;
  88.     while((auxiliar%30!=0) && (auxiliar>30)){
  89.         auxiliar-=30;
  90.         contador++;
  91.     }
  92.     if(contador>temp1->sala){
  93.         while(flag){
  94.         int auxiliar2 = contador - temp1->sala;
  95.         int sala_proposta;
  96.         printf("As salas sao insuficientes para o numero de alunos, por favor requisite mais %d sala(s).\n Qual e a sala?\n   ",contador );
  97.         scanf("%d",&sala_proposta);
  98.         int confirmar = confirmar_sala(&headexame,sala_proposta,temp1);
  99.         salas->next=NULL;
  100.         salas->numero=sala_proposta;
  101.         if(confirmar==0)
  102.             printf("A sala nao se encontra disponivel, escolha outra.");
  103.         else if(confirmar==1){
  104.             while(temp1->ssala->next==NULL)
  105.                 temp1->ssala=temp1->ssala->next;
  106.             temp1->ssala->next=salas;
  107.             printf("A sala foi reservada.");
  108.             flag =0;
  109.         }
  110.         }
  111.     }
  112.  }
  113.  
  114. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement