#include <stdio.h>
#include <stdlib.h>
#define SIZE 10
int v1,v2,v3,v4,v5,v6,v7,v8,v9,v10;
char*prod[]={"Dulces","Palomitas","Cigarros","Galletas","Churritos","Refrescos","Agua","Chicles","Halls","Chocolates"};
main (int argc, char* argv[])
{
int x;
printf("1. Facturación, 2.Histograma\n");
scanf("%d", &x);
if (x==1)
{
printf("Entramos en Facturación\n");
printf("Dulces: \n");
scanf("%d",&v1);
printf("Palomitas: \n");
scanf("%d",&v2);
printf("Cigarros: \n");
scanf("%d",&v3);
printf("Galletas: \n");
scanf("%d",&v4);
printf("Churritos: \n");
scanf("%d",&v5);
printf("Refrescos: \n");
scanf("%d",&v6);
printf("Agua: \n");
scanf("%d",&v7);
printf("Chicles: \n");
scanf("%d",&v8);
printf("Halls: \n");
scanf("%d",&v9);
printf("Chocolates: \n");
scanf("%d",&v10);
int n[SIZE]={v1,v2,v3,v4,v5,v6,v7,v8,v9,v10};
int i,j;
printf("%s%13s%23s%27s\n","CLAVE","PRODUCTO","CANTIDAD","PRECIO", "IMPORTE");
for (i=0;i<=SIZE-1;i++)
{
printf("%7d%13s%17d ",i,prod[i],n[i]);
// printf("precio\n");
for(j=1;j<=n[i];j++){
switch(i){
case 0 :printf("10 \n");
break;
case 1: printf("20\n");
break;
case 2: printf("20\n");
break;
case 3: printf("30\n");
break;
case 4: printf("40\n");
break;
case 5: printf("50\n");
break;
case 6: printf("60\n");
break;
case 7: printf("70\n");
break;
case 8: printf("80\n");
break;
case 9: printf("90\n");
break;
printf("\n");
}
}
//return 0;
}
}
else
{
printf("Entramos a histograma\n");
printf("Dulces: \n");
scanf("%d",&v1);
printf("Palomitas: \n");
scanf("%d",&v2);
printf("Cigarros: \n");
scanf("%d",&v3);
printf("Galletas: \n");
scanf("%d",&v4);
printf("Churritos: \n");
scanf("%d",&v5);
printf("Refrescos: \n");
scanf("%d",&v6);
printf("Agua: \n");
scanf("%d",&v7);
printf("Chicles: \n");
scanf("%d",&v8);
printf("Halls: \n");
scanf("%d",&v9);
printf("Chocolates: \n");
scanf("%d",&v10);
int n[SIZE]={v1,v2,v3,v4,v5,v6,v7,v8,v9,v10};
int i,j;
printf("%s%13s%13s%17s\n","CLAVE","PRODUCTO","CANTIDAD","HISTOGRAMA");
for (i=0;i<=SIZE-1;i++)
{
printf("%7d%13s%7d ",i,prod[i],n[i]);
for(j=1;j<=n[i];j++){
printf("%c",'$');
printf("\n");
}
//return 0;
}
}
system("pause");
}
No hay comentarios:
Publicar un comentario