Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <conio.h>
- #include <string.h>
- #define LIM 51
- #define TFC 2
- #define TFV 500
- #define TFP 5
- #define TFCOL 3
- int main()
- {
- char nomesCli[TFC][LIM], nomesProd[TFP][LIM], cliAux[LIM], prodAux[LIM];
- int matVendas[TFV][TFCOL], posProd, posCli, l, c, cont, tlVendas = 0, estoque[TFP], qntd;
- float preco[TFP], totParc, totVenda;
- printf("Cadastro de clientes\n");
- for(l = 0; l < TFC; l++)
- {
- printf("Digite o nome do %do cliente:\n", l+1);
- fflush(stdin);
- gets(nomesCli[l]);
- }
- printf("Cadastro de produtos\n");
- for(l = 0; l < TFP; l++)
- {
- printf("Digite o nome do %do produto:\n", l+1);
- fflush(stdin);
- gets(nomesProd[l]);
- printf("Digite o preco:\n");
- scanf("%f", &preco[l]);
- printf("Digite a quantidade em estoque:\n");
- scanf("%d", &estoque[l]);
- }
- printf("Digite o nome do cliente:\n");
- fflush(stdin);
- gets(cliAux);
- while(tlVendas < TFV && strcmp(cliAux, "") != 0)
- {
- posCli = 0;
- while(posCli < TFC && strcmp(cliAux, nomesCli[posCli]) != 0)
- posCli++;
- if(posCli == TFC)
- printf("Cliente inexistente\n");
- else
- {
- printf("Digite o nome do produto:\n");
- fflush(stdin);
- gets(prodAux);
- while(tlVendas < TFV && strcmp(prodAux, "") != 0)
- {
- posProd = 0;
- while(posProd < TFP && strcmp(prodAux, nomesProd[posProd]) != 0)
- posProd++;
- if(posProd == TFP)
- printf("Produto inexistente\n");
- else
- {
- printf("Digite a quantidade:\n");
- scanf("%d", &qntd);
- if(estoque[posProd] < qntd)
- printf("Estoque insuficiente\n");
- else
- {
- matVendas[tlVendas][0] = posCli;
- matVendas[tlVendas][1] = posProd;
- matVendas[tlVendas][2] = qntd;
- estoque[posProd] -= qntd;
- tlVendas++;
- printf("Venda efetuada\n");
- }
- }
- if(tlVendas < TFV)
- {
- printf("Digite o nome do produto:\n");
- fflush(stdin);
- gets(prodAux);
- }
- }
- }
- if(tlVendas < TFV)
- {
- printf("Digite o nome do cliente:\n");
- fflush(stdin);
- gets(cliAux);
- }
- }
- for(l = 0; l < tlVendas; l+= cont)
- {
- cont = 0;
- totVenda = 0;
- printf("Cliente: %d - %s\n", matVendas[l][0], nomesCli[matVendas[l][0]]);
- for(c = l; c < tlVendas && matVendas[c][0] == matVendas[l][0]; c++)
- {
- printf("Produto %d - %s ", matVendas[c][1], nomesProd[matVendas[c][1]]);
- printf("Preco: %.2f ", preco[matVendas[c][1]]);
- printf("Quantidade: %d ", matVendas[c][2]);
- totParc = preco[matVendas[c][1]] * matVendas[c][2];
- printf("Total: %.2f\n", totParc);
- totVenda += totParc;
- cont++;
- }
- printf("Total da Venda: %.2f\n\n", totVenda);
- }
- printf("\nExibicao dos produtos em estoque\n\n");
- for(l = 0; l < TFP; l++)
- {
- printf("Produto: %d - %s ", l, nomesProd[l]);
- printf("Preco: %.2f ", preco[l]);
- printf("Quantidade em estoque: %d\n", estoque[l]);
- printf("\n");
- }
- getch();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement