Anderson Soares Posted November 10, 2015 at 01:23 AM Report Share #589573 Posted November 10, 2015 at 01:23 AM Olá amigos, Estou desenvolvendo meu primeiro sistema em C++, e estou com uma dúvida no código. É um sistema de vendas de passagem de ônibus, onde eu preciso adicionar um if e um for (no case 4), onde os lugares 1 e 2 sejam reservados para pessoas >=60 anos. E outro if para estudantes que pagaram meia passagem. Alguém pode me ajudar? #include <stdio.h> #include <string.h> int main() { int a[12][3], l, c, menu, soma, qtd, idade, lugar, t, qa; qtd = 0; idade = 0; soma = 0; qa = 0; menu = 0; t = 0; for (l=0;l<12;l++) { for (c=0;c<3;c++) { qtd++; a[l][c] = qtd; } } while (menu!=6) { printf("\n**********menu***********"); printf("\n*1-vendidas *"); printf("\n*2-vagas na janela *"); printf("\n*3-vagas no corredor *"); printf("\n*4-vender passagem *"); printf("\n*5-total arrecadado *"); printf("\n*6-sair *"); printf("\n*************************"); printf("\nopcao: "); scanf("%d", &menu); system("cls"); switch (menu) { case 1: for (l=0;l<12;l++) { for (c=0;c<3;c++) { if (a[l][c]==0) { printf("[ v] "); } else { printf("[ %d] ", a[l][c]); } } printf("\n"); } break; case 2: for (l=0;l<12;l++) { for (c=0;c<3;c++) { if (a[l][c]==0) { printf("[ v ]"); } else if (c==0 || c==3) { printf("[ %d] ", a[l][c]); } else if (c==1 || c==2) { printf("[ ] "); } } printf("\n"); } break; case 3: for (l=0;l<12;l++) { for (c=0;c<3;c++) { if (a[l][c]==0) { printf("[ v] "); } else if (c==1 || c==2) { printf("[ %d] ", a[l][c]); } else if (c==0 || c==3) { printf("[ ] "); } } printf("\n"); } break; case 4: volta: printf("\nDigite a idade:"); scanf("%d", &idade); printf("\nvalor da passagem 15R$"); printf("\ndigite o lugar: "); scanf("%d", &lugar); if (lugar>=1 && lugar<=36) { soma++; qa++; for (l=0;l<12;l++) { for(c=0;c<3;c++) { if (a[l][c]==lugar) { a[l][c]=0; } } } } else { printf("\nlugares de 1 a 36\n"); goto volta; } break; case 5: printf("\nvalor da passagem 15R$"); for (l=0;l<12;l++) { for (c=0;c<3;c++) { if (a[l][c]==0) { t = soma * 15; } } } printf("\npassagens vendidas %d", qa); printf("\ntotal %dR$\n", t); break; default : printf("\ndigite uma opcao valida\n"); break; } } } Link to comment Share on other sites More sharing options...
bubulindo Posted November 18, 2015 at 02:53 PM Report Share #589854 Posted November 18, 2015 at 02:53 PM Nao queres dizer onde arranjaste esse codigo? Alguem que escreve tudo isso e nao consegue escrever uma condicao if... parece-me um pouco estranho. 1 Report include <ai se te avio> Mãe () { } Link to comment Share on other sites More sharing options...
h9armando Posted December 26, 2015 at 12:06 AM Report Share #591048 Posted December 26, 2015 at 12:06 AM (edited) Nao queres dizer onde arranjaste esse codigo? Alguem que escreve tudo isso e nao consegue escrever uma condicao if... parece-me um pouco estranho. Chibás-te-o todo. 😛😄😁 Edited December 26, 2015 at 12:07 AM by h9armando Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now