Olá a todos.
Sou novo no fórum, iniciante em linguagem C e estou com muitas dificuldades em resolver um exercício.
Preciso de um programa com a opção "2"em um menu, para gerar um relatório do número de passagens vendidas.
Tenho de completar o arquivo abaixo que já foi pré-determinado pelo curso.
Agradeço a quem possa ajudar.
#include<stdio.h>
#include<conio.h>
// PROGRAMA PARA VENDA DE PASSAGENS
int main()
{
int op,L,COL,P;
int poltrona[2][2]; // [2 LINHAS][2 COLUNAS];
// DISTRIBUIÇÃO DAS POLTRONAS NO PROGRAMA:
// poltrona[0][0]=1 poltrona[0][1]=2
// poltrona[1][0]=3 poltrona[1][1]=4
for (L=0;L<=1;L++)
{
for (COL=0;COL<=1;COL++)
{
poltrona[L][COL]=0; // PERCORRE CADA POSIÇÃO DA MATRIZ E ATRIBUI ZERO
}
}
printf("\n \n \t --- PROGRAMA PARA VENDA DE PASSAGENS --- \n \n");
do
{
printf("\n \n 1-COMPRAR");
printf("\n \n 2-RELATORIO");
printf("\n \n 0-SAIR -->> ");
scanf("%d",&op);
switch(op)
{
case 0:
printf("\n \n Programa finalizado, pressione qualquer tecla...");
break;
case 1:
printf("\n POLTRONA DESEJADA: ");
scanf("%d",&P);
if (P==1)
{
if (poltrona[0][0]==1)
{
printf("\n *** POLTRONA OCUPADA ***");
}
if (poltrona[0][0]==0)
{
printf("\n *** POLTRONA VENDIDA COM SUCESSO ***");
poltrona[0][0]=1;
}
}
if (P==2)
{
if (poltrona[0][1]==1)
{
printf("\n *** POLTRONA OCUPADA ***");
}
if (poltrona[0][1]==0)
{
printf("\n *** POLTRONA VENDIDA COM SUCESSO ***");
poltrona[0][1]=1;
}
}
if (P==3)
{
if (poltrona[1][0]==1)
{
printf("\n *** POLTRONA OCUPADA ***");
}
if (poltrona[1][0]==0)
{
printf("\n *** POLTRONA VENDIDA COM SUCESSO ***");
poltrona[1][0]=1;
}
}
if (P==4)
{
if (poltrona[1][1]==1)
{
printf("\n *** POLTRONA OCUPADA ***");
}
if (poltrona[1][1]==0)
{
printf("\n *** POLTRONA VENDIDA COM SUCESSO ***");
poltrona[1][1]=1;
}
}
break;
case 2:
printf("\n \n RELATORIO DE VENDAS \n\n");
break;
default:
printf("\n \n<<< SELECIONE 1 OU 0 >>>");
break;
}
}while(op!=0);
getch();
}