Advertisement
plantbae

Estructuras anidadas

Feb 16th, 2015
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.15 KB | None | 0 0
  1. #include <iostream>
  2. #define ELEMENTOS 10
  3. using namespace std;
  4.  
  5. /*Estructuras que tienen como miembros otras estructuras. Ayudan a tener la estrutura de datos más organizada*/
  6. struct estruc_existencias
  7. {
  8. int cintas, cd;
  9. };
  10. struct estruc_proveedor
  11. {
  12. char nombre_proveedor[40], telefono_proveedor[10], direccion_proveedor[100];
  13. };
  14. struct estruc_inventario
  15. {
  16. char titulo[30], autor[40];
  17. //Se define la llave de estruc_existencias y estruc_proveedor dentro de estruc_inventario para anidarlas
  18. struct estruc_existencias existencias[ELEMENTOS];
  19. struct estruc_proveedor proveedor[ELEMENTOS];
  20. }inventario[ELEMENTOS];
  21.  
  22.  
  23. int tomar_datos(struct estruc_inventario inventario)
  24. {
  25. cout << "¿Cuántos proveedores desea almacenar en el sistema?" << endl;
  26. int num_proveedores;
  27. for (int i = 0; i < num_proveedores; i++)
  28. {
  29. cout << "Nombre del proveedor" << endl;
  30. //Se necesitan varios inventarios!! anidar en ciclo for, pero del proveedor sí se pueden tener varios proveedores
  31. cin >> inventario[i].proveedor[i].nombre_proveedor;
  32. cout << "Teléfono del proveedor" << inventario.proveedor[i].nombre_proveedor << endl;
  33. cin >> inventario.proveedor[i].telefono_proveedor;
  34. cout << "Dirección del proveedor" << inventario.proveedor[i].nombre_proveedor << endl;
  35. cin >> inventario.proveedor[i].direccion_proveedor;
  36. cout << "¿El proveedor " << inventario.proveedor[i].nombre_proveedor << "suministra cintas? Si es así, digite el número suministrado. En caso contrario, digite 0" << endl;
  37. int num_cintas;
  38. inventario.existencias[i].cintas += num_cintas;
  39. do
  40. {
  41. for (int i = 0; i < num_cintas; i++)
  42. {
  43.  
  44.  
  45. }
  46. } while (num_cintas != 0);
  47. }
  48. }
  49. void main(){
  50. cout << "Tienda de música\n\n1. Ingresar datos de proveedor\n2. Ver existencias\n3. Ver inventario. ";
  51. int switch_on;
  52. cin >> switch_on;
  53. switch (switch_on)
  54. {
  55. case 1:
  56. tomar_datos(inventario);
  57. break;
  58. default:
  59. break;
  60. }
  61. tomar_datos();
  62.  
  63. /*
  64. cout << "nota 1 : " << endl;
  65. cin >> ptrn->nota1;
  66. cout << "nota 2 : " << endl;
  67. cin >> ptrn->nota2;
  68. cout << "nota 3 : " << endl;
  69. cin >> ptrn->nota3;
  70. ptrn = notas;
  71. */
  72. system("pause>null");
  73. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement