PROGRAMA EM C

have a problem in a work of the university, I can not change the variables of char to integer, need help, can someone? I'll post the enuciado and the program can do, but he grabbed it and this problem, if anyone can help thank you very já.Um hug everyone.FOLLOW THE CODE.

Atc

CLAUDIO
THIS IS THE problem statement



1, Practical Work

A tour company needs a control system for their bus seats. Each
has nine rows of coach seats. In each row, four armchairs, two side
right (driver) and two on the left side (ladder). There are then 36 seats per bus, as
the figure below.





Consider that for the storage of information we will work with the following
array variable (with four rows and nine columns):

char bus [4] [9];

This variable should be initially filled with 0 (zero) in each position. Relying
this information to build a C program can fill a vacancy on the bus.
For this, you should consider the following information:
row: stores the Walloons 1-9; 1.
hand, contains the values "right" or "left" 2.
armchair can have the values "window" or "corridor". 3.
If the vacancy is occupied, the program should display an error message for
user. In addition, the program must submit a report of vacancies, as the example
below:

#include<stdio.h>
#include<stdlib.h>

int main(void)
{
int linha, coluna, fileira, lado, poltrona, i=0, cont_vazia=0, cont_ocupada=0, cont_janela=0, cont_corredor=0;
int onibus[4][9];

// Atribui 0 a matriz
for(linha = 0; linha < 4; linha++)
{
for(coluna = 0; coluna < 9; coluna++)
{
onibus[linha][coluna] = 0;
}
}

do{ //retirar



//---------------------- listar --------------------------------------------
cont_vazia=0; cont_ocupada=0; //cont_janela=0; cont_corredor=0;
//lista a matriz
for(linha = 0; linha < 4; linha++)
{
printf("\n\t%d ", linha+1); //custon
for(coluna = 0; coluna < 9; coluna++)
{
printf("%d ", onibus[linha][coluna]);
if(onibus[linha][coluna] == 0)
{
cont_vazia = cont_vazia+1;
}
else
{
cont_ocupada = cont_ocupada+1;
}
}
}

printf("\n\tPessoas na Janela: %d", cont_janela);
printf("\n\tPessoas no Corredor: %d", cont_corredor);
printf("\n\tTotal Ocupadas: %d", cont_ocupada);
printf("\n\tTotal Vazias: %d", cont_vazia);

//---------------------ocupar vaga------------------------------------------
printf("\n\n\n\t.::RESERVA DE VAGA::.\n");
printf("\n\t => Informe a fileira (1 a 9): ");
scanf("%d", &fileira);
printf("\n\t => Informe o lado (0-Direito ou 1-Esquerdo): ");
scanf("%d", &lado);
printf("\n\t => Informe a poltrona (0-Janela ou 1-Corredor): ");
scanf("%d", &poltrona);
// cobrador inicio
if(lado == 0)
{
if (poltrona == 0)
{
linha = 0;
cont_janela = cont_janela+1;
}
else if(poltrona == 1)
{
linha = 1;
cont_corredor = cont_corredor+1;
}
}
else if(lado == 1)
{
if(poltrona == 0)
{
linha = 3;
cont_janela = cont_janela+1;
}
else if(poltrona == 1)
{
linha = 2;
cont_corredor = cont_corredor+1;
}
}
coluna = fileira - 1;
//cobrador fim (localiza a poltrona)

if(onibus[linha][coluna] == 8)
{
printf("\n\tA poltrona esta ocupada");

//Colocar um bip
}
else
{
onibus[linha][coluna] = 8;
}

i++;
}while(i<10);

printf("\n\n\t");
system("pause");
return 0;
}





Ouvir
Ler foneticamente
Dicionário - Ver dicionário detalhado
Que serviço porco essa tradução!
Topic archived. No new replies allowed.