Guest User

Untitled

a guest
Apr 21st, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.72 KB | None | 0 0
  1. #include<stdio.h>
  2. int main(){
  3. int x=10, i=0, fumo, cont, f=0, nf=9, conf;
  4. int aviao[x];
  5.  
  6. for(i=0 ; i<x ; i++){ //for pra inicializar o array com 0 em todas as posições
  7. aviao[i]=0;
  8. }
  9. for(i=0 ; i<x ; i++){ //entrada de reserva das passagens.
  10. scanf("%d", &fumo);
  11. if(fumo==1){ //seleção de fumante ou nao fumante
  12. aviao[f]=1; //a variavel f tem valor 0, e incrementa ate 4 pra delimitar os assentos
  13. f+=1;
  14. if(f>4){ //quando chegar em 4 esgota os assentos
  15. printf("assento indisponivel, quer ir com as caipora? 1=s / 2=n");
  16. scanf("%d", &conf);
  17. if(conf==1){
  18. aviao[nf]=1;
  19. nf-=1;
  20. }else if(conf==2){
  21. printf("PROXIMO VOO SAI EM 10 HORAS. SE ARROMBA AE! -.-");
  22. }
  23. }
  24. }else if(fumo==2){//seleção de fumante ou nao fumante
  25. aviao[nf]=1; //nf começa em 9, e decrementa ate 5
  26. nf-=1;
  27. if(nf<5){ //limite de assentos
  28. printf("assento indisponivel, vai sem fumar, safadinho... DESEJA IR COM OS NAO FUMANTES? 1=s / 2=n");
  29. scanf("%d", &conf);
  30. if(conf==1){
  31. aviao[f]=1;
  32. nf+=1;
  33. }else if(conf==2){
  34. printf("PROXIMO VOO SAI EM 10 HORAS. SE ARROMBA AE! -.-");
  35. }
  36. }
  37. }
  38. }
  39. return 0;
  40. }
Add Comment
Please, Sign In to add comment