document.write('
Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. /*
  2.     Autor: Joel Cesar Fernandez Segura
  3.     Curso: Estructura de Datos
  4.     Ejercicio: VENTA DE POSTRES
  5.     IDE: CodeBlocks
  6.     Pagina Web: http://codebotic.blogspot.com
  7.  
  8. */
  9. #include<iostream>
  10. #include<cstdlib>
  11. #define maxchar 50
  12.  
  13. using namespace std;
  14.  
  15. struct nodo2{
  16.     char ingrediente[maxchar];
  17.  
  18. };
  19.  
  20. struct nodo{
  21.  
  22.     char nombre[maxchar];
  23.     float precio;
  24.     int codigo;
  25.     int cantIngred;
  26.     nodo2 ingred[maxchar];
  27.     struct nodo *sgte;
  28.  
  29. };
  30.  
  31. typedef struct nodo *TPostre;
  32.  
  33. /*-------------------- FUNCION MENU PRINCIPAL ------------------*/
  34. void menu(void){
  35.  
  36.     cout<<"\\n\\t\\t[       VENTA DE POSTRES       ]\\n";
  37.     cout<<"\\t\\t--------------------------------\\n\\n";
  38.     cout<<" 1. REGISTRAR POSTRE                          "<<endl;
  39.     cout<<" 2. LISTAR POSTRES                            "<<endl;
  40.     cout<<" 3. VENDER POSTRE                             "<<endl;
  41.     cout<<" 4. SALIR                                     "<<endl;
  42.  
  43.     cout<<"\\n Ingrese opcion : ";
  44. }
  45.  
  46. /*------------------- FUNCION REGISTRAR UN POSTRE ------------------*/
  47. void registrar_postre(TPostre &lista){
  48.  
  49.     TPostre t,q = new(struct nodo);
  50.  
  51.     cout<<"\\n\\n\\t\\t[  REGISTRO  ]\\n";
  52.     cout<<"\\t\\t------------";
  53.  
  54.     cout<<"\\n\\tDATOS DEL POSTRE \\n";
  55.     cout<<"\\n\\tCODIGO DE VENTA:"; cin>>q->codigo;
  56.     cin.ignore();cout<<"\\n\\tNOMBRES:"; cin.getline(q->nombre,maxchar);
  57.     cout<<"\\n\\tPRECIO:"; cin>>q->precio;
  58.  
  59.     cout<<"\\n\\tIngrese Cantidad de Ingredientes:";
  60.     cin>>q->cantIngred;
  61.  
  62.     for(int i=0;i<q->cantIngred;i++){
  63.  
  64.         cin.ignore();
  65.         cout<<"\\n\\tIngrese ingrediente # "<<i+1<<"  : ";
  66.         cin.getline(q->ingred[i].ingrediente,maxchar);
  67.  
  68.     }
  69.  
  70.     cout<<endl;
  71.  
  72.     system("cls");
  73.  
  74.     q->sgte = NULL;
  75.  
  76.     if(lista==NULL){
  77.  
  78.         lista = q;
  79.  
  80.     } else {
  81.  
  82.         t = lista;
  83.  
  84.         while(t->sgte!=NULL){
  85.  
  86.                 t = t->sgte;
  87.         }
  88.  
  89.         t->sgte = q;
  90.  
  91.     }
  92. }
  93.  
  94. /*-------------------- MOSTRAR LISTA DE POSTRES ------------------*/
  95. void listar_postres(TPostre q){
  96.  
  97.     int i=1;
  98.  
  99.     while(q!=NULL){
  100.  
  101.         cout<<"\\n\\n\\tDATOS DEL POSTRE ["<<i<<"] ";
  102.         cout<<"\\n\\t------------------------";
  103.         cout<<"\\n\\tCODIGO DE VENTA: "<<q->codigo<<endl;
  104.         cout<<"\\n\\tNOMBRE  : "<<q->nombre<<endl;
  105.         cout<<"\\n\\tPRECIO : "<<q->precio<<endl;
  106.         cout<<"\\n\\tINGREDIENTES:"<<endl;
  107.  
  108.         for(int j=0;j<q->cantIngred;j++){
  109.             cout<<endl<<"\\t"<<j+1<<".- "<<q->ingred[j].ingrediente;
  110.         }
  111.  
  112.         q=q->sgte;
  113.  
  114.         i++;
  115.     }
  116.  
  117. }
  118.  
  119. /*-------------------- FUNCION VENDER POSTRE  ------------------*/
  120. void vender_postre(TPostre q){
  121.  
  122.     int cant;
  123.     int cod;
  124.  
  125.     cout<<"\\n\\n\\n\\t";
  126.     cout<<"\\n\\n\\tINGRESE CODIGO DE VENTA:"; cin>>cod;
  127.  
  128.     while(q!=NULL){
  129.  
  130.             if(q->codigo==cod){
  131.  
  132.                 system("cls");
  133.  
  134.                 cout<<"\\n\\tDATOS DEL  POSTRE";
  135.                 cout<<"\\n\\t--------------------";
  136.                 cout<<"\\n\\n\\tCODIGO   : "<<q->codigo<<endl;
  137.                 cout<<"\\n\\tNOMBRE  : "<<q->nombre<<endl;
  138.                 cout<<"\\n\\tPRECIO  : "<<q->precio<<endl;
  139.                 cout<<"\\n\\tINGREDIENTES:"<<endl;
  140.  
  141.                 for(int j=0;j<q->cantIngred;j++){
  142.  
  143.                     cout<<endl<<"\\t"<<j+1<<".- "<<q->ingred[j].ingrediente;
  144.                 }
  145.  
  146.                 cout<<"\\n\\n\\tINGRESE CANTIDAD DE PORCIONES:";
  147.                 cin>>cant;
  148.                 cout<<"\\n\\n\\tTOTAL A PAGAR:"<<cant*q->precio;
  149.                 cout<<"\\n\\n\\tGRACIAS POR SU COMPRA.....!!!!!!";
  150.  
  151.                 return;
  152.  
  153.             }else {
  154.  
  155.  
  156.                 q=q->sgte;
  157.  
  158.         }
  159.  
  160.     }
  161.     if(q==NULL)
  162.         cout<<"\\n\\tCODIGO INCORRECTO...!!\\n";
  163. }
  164.  
  165.  
  166.  
  167. /*------------------------FUNCION PRINCIPAL-------------------------*/
  168. int main(void){
  169.  
  170.     system("color 0a");
  171.  
  172.     TPostre lista=NULL;
  173.  
  174.     int op;
  175.  
  176.     do{
  177.             menu();
  178.             cin>>op;
  179.  
  180.             switch(op){
  181.  
  182.                 case 1: registrar_postre(lista);
  183.                         break;
  184.  
  185.                 case 2: listar_postres(lista);
  186.                         break;
  187.  
  188.                 case 3: vender_postre(lista);
  189.                         break;
  190.  
  191.                 case 4: return 0;
  192.  
  193.  
  194.                 default: cout<<"\\nINGRESE UNA OPCION VALIDA...\\n"; break;
  195.  
  196.             }
  197.             cout<<endl;
  198.             system("pause");  system("cls");
  199.  
  200.         }while(op!=6);
  201.  
  202.     system("pause");
  203.  
  204. return 0;
  205. }
');