Ir para conteúdo
Fórum Script Brasil

davidrocha79

Membros
  • Total de itens

    2
  • Registro em

  • Última visita

Tudo que davidrocha79 postou

  1. Ola muito obrigado ,mas eu iniciei já o meu projeto irei fazer dois um atraves desse metodo,mas o meu ficou assim: #include <stdio.h> #include <stdlib.h> #include <conio.h> int snacks[20]={3,5,6,7,8,9,1,0,2,3,4,5,6,7,4,7,6,3,2,1} ; void menu () { printf("\n\t So moedas de 5 10 20 50 100 200") ; printf("\n\t 1 Sprite\t\t(95 centimos)\t"); if (snacks[0] <= 0) printf("esgotado"); printf("\n\t (2) Queijo Fresco\t(85 centimos)\t"); if (snacks[1] <= 0) printf("esgotado"); printf("\n\t (3) Sumol\t\t(70 centimos)\t"); if (snacks[2] <= 0) printf("esgotado"); printf("\n\t (4) Agua\t\t(50 centimos)\t"); if (snacks[3] <= 0) printf("esgotado"); printf("\n\t (5) Mnt Dew\t\t(60 centimos)\t"); if (snacks[4] <= 0) printf("esgotado"); printf("\n\t (6) Doritos\t\t(40 centimos)\t"); if (snacks[5] <= 0) printf(""); printf("\n\t (7) Pringles\t\t(20 centimos)\t"); if (snacks[6] <= 0) printf(""); printf("\n\t (8) Lays\t\t(95 centimos)\t"); if (snacks[7] <= 0) printf(""); printf("\n\t (9) Agua\t\t(40 centimos)\t"); if (snacks[8] <= 0); printf(""); printf("\n\t (10) Vinho\t\t(50 centimos)\t"); if (snacks[9]<= 0); printf(""); printf("\n\t (11) Sumol\t\t(60centimos)\t"); if (snacks[10] <= 0); printf(""); printf("\n\t (12) Agua com sal\t(70 centimos)\t"); if (snacks[11] <= 0); printf(""); printf("\n\t (13) cacau\t\t(40 centimos)\t"); if (snacks[12] <= 0); printf(""); printf("\n\t (14) Azeitonas\t\t(50 centimos)\t"); if (snacks[13]<= 0); printf(""); printf("\n\t (15) Bolachas\t\t(25 centimos)\t"); if (snacks[14] <= 0); printf(""); printf("\n\t (16) Copos\t\t(20 centimos)\t"); if (snacks[15] <= 0); printf(""); printf("\n\t (17) Livros\t\t(40 centimos)\t"); if (snacks[16] <= 0); printf(""); printf("\n\t (18) Kit Kat\t\t(30 centimos)\t"); if (snacks[17] <= 0); printf(""); printf("\n\t (19) Gomas\t\t(65 centimos)\t"); if (snacks[18] <= 0); printf(""); printf("\n\t (20) Gelados\t\t(40 centimos)\t"); if (snacks[19] <= 0); printf(""); printf("\n\t%c", 192); for (int i=1; i<48; i++) printf("%c", 196); printf("%c", 217); } int insertcoin (int custo) { int creditos=0, moeda; do { printf("\n\tCreditos= %d. ", creditos); printf("Em falta = %d.", creditos<custo? custo-creditos: 0); printf("\n\tInsira moeda: "); scanf("%d", &moeda); fflush(stdin); if (moeda==5 || moeda==10 || moeda==20 || moeda==50 || moeda==100 || moeda==200) creditos += moeda; } while (creditos < custo); return creditos; } void vercreditos (int custo, int creditos) { if (creditos > custo) printf("\n\tO seu troco= %d.", creditos-custo); printf("\n\tRetire a sua bebida/snack. Obrigado.\n\n"); system("pause"); } int main() { int op, custo=0, creditos; do { menu (); printf("\n\n\t Digite a sua op%c%co: ", 135, 198); scanf("%d", &op); fflush(stdin); if (op!=-99) { switch(op) { case 1 : printf("\n\tMars\n"); custo=95; if (snacks[0] > 0) snacks[0] -= 1; else { custo == 0; printf("produto esgotado"); } break; case 2 : printf("\n\tTwix\n"); custo=85; if (snacks[1] > 0) snacks[1] -= 1; else { custo == 0; printf("produto esgotado"); } break; case 3 : printf("\n\tCoca-cola\n"); custo=70; if (snacks[2] > 0) snacks[2] -= 1; else { custo == 0; printf("produto esgotado"); } break; case 4 : printf("\n\tAgua\n"); custo=40; if (snacks[3] > 0) snacks[3] -= 1; else { custo == 0; printf("produto esgotado"); } break; case 5 : printf("\n\tMnt Dew\n"); custo=50; if (snacks[4] > 0) snacks[4] -= 1; else { custo == 0; printf("produto esgotado"); } break; case 6 : printf("\n\tDoritos\n"); custo=60; if (snacks[5] > 0) snacks[5] -= 1; else { custo == 0; printf("produto esgotado"); } break; case 7 : printf("\n\tPringles\n"); custo=20; if (snacks[6] > 0) snacks[6] -= 1; else { custo == 0; printf("produto esgotado"); } break; case 8 : printf("\n\tLays\n"); custo=95; if (snacks[7] > 0) snacks[7] -= 1; else { custo == 0; printf("produto esgotado"); } break; case 9 : printf("\n\tAgua\n"); custo=40; if (snacks[6] > 0) snacks[6] -= 1; else { custo == 0; printf("produto esgotado"); } break; case 10 : printf("\n\tVinho\n"); custo=70; if (snacks[7] > 0) snacks[7] -= 1; else { custo == 0; printf("produto esgotado"); } break; case 11 : printf("\n\tSumol\n"); custo=40; if (snacks[8] > 0) snacks[8] -= 1; else { custo == 0; printf("produto esgotado"); } break; case 12 : printf("\n\tAgua com Sal\n"); custo=70; if (snacks[9] > 0) snacks[9] -= 1; else { custo == 0; printf("produto esgotado"); } break; case 13 : printf("\n\tcacau\n"); custo=40; if (snacks[10] > 0) snacks[10] -= 1; else { custo == 0; printf("produto esgotado"); } break; case 14 : printf("\n\tAzeitonas"); custo=50; if (snacks[11] > 0) snacks[11] -= 1; else { custo == 0; printf("produto esgotado"); } break; case 15 : printf("\n\tBolachas\n"); custo=25; if (snacks[12] > 0) snacks[12] -= 1; else { custo == 0; printf("produto esgotado"); } break; case 16 : printf("\n\tCopos\n"); custo=20; if (snacks[13] > 0) snacks[13] -= 1; else { custo == 0; printf("produto esgotado"); } break; case 17 : printf("\n\tLivros\n"); custo=40; if (snacks[14] > 0) snacks[14] -= 1; else { custo == 0; printf("produto esgotado"); } break; case 18 : printf("\n\tKit Kat\n"); custo=30; if (snacks[15] > 0) snacks[15] -= 1; else { custo == 0; printf("produto esgotado"); } break; case 19 : printf("\n\tGomas\n"); custo=65; if (snacks[16] > 0) snacks[16] -= 1; else { custo == 0; printf("produto esgotado"); } break; case 20 : printf("\n\Gelados/n"); custo=40; if (snacks[17] > 0) snacks[17] -= 1; else { custo == 0; printf("produto esgotado"); } break; default: printf("\n\toperacao invalida."); custo=0; getch(); } if (custo>0) { creditos = insertcoin(custo); vercreditos(custo, creditos); } } } while (op!=-99); puts("\t\t\t---bye---"); return 0; }
  2. Bom dia,eu estou com algumas duvidas de como se insere arrays em c++,o meu professor deu-me um trabalho de fazer em que devia fazer uma maquina de snacks com: Existem 20 produtos disponíveis na máquina; Cada produto tem um stock de quantidade inicial (máximo de 15); Para cada produto vendido a quantidade será atualizada; Em caso de existência de 0 (zero) o produto deverá exibir a legenda “ESGOTADO” em substituição do preço no menu; Não permitir a venda do produto esgotado; Possibilitar a atualização de stock de um qualquer produto (usar a opção -99 para definir um novo submenu); Quando a máquina for desligada deve exibir a quantidade existente e o total de vendas para cada produto; A máquina deverá utilizar um algoritmo guloso na realização do troco (OPCIONAL). já comecei o codigo alguém me poderia ajudar a por arrays ? #include <stdio.h> #include <stdlib.h> #include <conio.h> int main() { int op, custo=0, moeda, creditos; do { system("cls"); printf("\t"); printf("%c", 218); for (int i=1; i<48; i++) printf("%c", 196); printf("%c", 191); printf("\n\t%c (1) Caf%c longo\t\t(70 c%cntimos)\t%c", 179, 130, 136, 179); printf("\n\t%c (2) Caf%c curto\t\t(70 c%cntimos)\t%c", 179, 130, 136, 179); printf("\n\t%c (3) Caf%c pingado\t\t(80 c%cntimos)\t%c", 179, 130, 136, 179); printf("\n\t%c (4) Cappucino\t\t\t(95 c%cntimos)\t%c", 179, 136, 179); printf("\n\t%c (5) Chocolate\t\t\t(85 c%cntimos)\t%c", 179, 136, 179); printf("\n\t%c (6) Gal%co\t\t\t(95 c%cntimos)\t%c", 179, 198, 136, 179); printf("\n\t%c (7) Ch%c de lim%co\t\t(60 c%cntimos)\t%c", 179, 160, 198, 136,179); printf("\n\t%c", 192); for (int i=1; i<48; i++) printf("%c", 196); printf("%c", 217); printf("\n\n\t Digite a sua op%c%co: ", 135, 198); scanf("%d", &op); fflush(stdin); if (op!=-99) { switch(op) { case 1 : printf("\n\tCaf%c longo", 130); custo=70; break; case 2 : printf("\n\tCaf%c curto", 130); custo=70; break; case 3 : printf("\n\tCaf%c pingado", 130); custo=80; break; case 4 : printf("\n\tCappucino"); custo=95; break; case 5 : printf("\n\tChocolate"); custo=85; break; case 6 : printf("\n\tGal%co", 132); custo=95; break; case 7 : printf("\n\tCh%c de lim%co", 160, 132); custo=60; break; default: printf("\n\tOp%c%co inv%clida.", 135, 132, 160); custo=0; getch(); } if (custo>0) { do { printf("\n\tCreditos= %d. ", creditos); printf("Em falta = %d.", creditos<custo? custo-creditos: 0); printf("\n\tInsira moeda: "); scanf("%d", &moeda); fflush(stdin); if (moeda==5 || moeda==10 || moeda==20 || moeda==50 || moeda==100 || moeda==200) creditos += moeda; } while (creditos < custo); if (creditos > custo) printf("\n\tO seu troco= %d.", creditos-custo); printf("\n\tRetire a sua bebida. Obrigado.\n\n"); system("pause"); } } } while (op!=-99); puts("\t\t\t---bye---"); return 0; }
×
×
  • Criar Novo...