Advertisement
Guest User

Elevador

a guest
May 5th, 2015
211
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.92 KB | None | 0 0
  1. //Por enquanto sรณ sobe
  2. #include <stdio.h>
  3.  
  4. int andares[10];
  5. int populacao = 0;
  6.  
  7. int main() {
  8.     printf("--------Elevador--------\n");
  9.     int i;
  10.     for(i = 0; i < 10; i++) {
  11.         printf("Andar %d\n", i + 1);
  12.         if(i == 9) {
  13.             printf("Ultimo andar, descem todos...\n\n\n");
  14.             continue;
  15.         }
  16.         populacao = populacao - andares[i];
  17.         printf("Desceram nesse andar %d alunos\n", andares[i]);
  18.         andares[i] = 0;
  19.         while(1) {
  20.             if(populacao >= 15) {
  21.                             printf("Elevador lotado!!!\nSeguindo...\n\n\n");
  22.                             break;
  23.                     }
  24.             int c;
  25.             printf("Atualmente %d pessoa(s) estao no elevador\n", populacao);
  26.             printf("Digite para qual andar o aluno deseja ir ou 0, caso tenha terminado de entrar os dados\n");
  27.             scanf("%d", &c);
  28.             if(c == 0) break;
  29.             (andares[c - 1])++;
  30.             populacao++;
  31.             printf("\n");
  32.         }
  33.         printf("\n----------------------\n\n");
  34.     }
  35.     printf("fim");
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement