Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- int main(){
- int x=10, i=0, fumo, cont, f=0, nf=9, conf;
- int aviao[x];
- for(i=0 ; i<x ; i++){ //for pra inicializar o array com 0 em todas as posições
- aviao[i]=0;
- }
- for(i=0 ; i<x ; i++){ //entrada de reserva das passagens.
- scanf("%d", &fumo);
- if(fumo==1){ //seleção de fumante ou nao fumante
- aviao[f]=1; //a variavel f tem valor 0, e incrementa ate 4 pra delimitar os assentos
- f+=1;
- if(f>4){ //quando chegar em 4 esgota os assentos
- printf("assento indisponivel, quer ir com as caipora? 1=s / 2=n");
- scanf("%d", &conf);
- if(conf==1){
- aviao[nf]=1;
- nf-=1;
- }else if(conf==2){
- printf("PROXIMO VOO SAI EM 10 HORAS. SE ARROMBA AE! -.-");
- }
- }
- }else if(fumo==2){//seleção de fumante ou nao fumante
- aviao[nf]=1; //nf começa em 9, e decrementa ate 5
- nf-=1;
- if(nf<5){ //limite de assentos
- printf("assento indisponivel, vai sem fumar, safadinho... DESEJA IR COM OS NAO FUMANTES? 1=s / 2=n");
- scanf("%d", &conf);
- if(conf==1){
- aviao[f]=1;
- nf+=1;
- }else if(conf==2){
- printf("PROXIMO VOO SAI EM 10 HORAS. SE ARROMBA AE! -.-");
- }
- }
- }
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment