#include <iostream>
#include <vector>
#include <string>
using namespace std;
struct Producto {
string nombre;
int cantidad;
double precio;
};
vector<Producto> inventario; // vector que almacena los productos
void agregarProducto() {
Producto p;
cout << "Ingrese el nombre del producto: ";
cin >> [Link];
cout << "Ingrese la cantidad del producto: ";
cin >> [Link];
cout << "Ingrese el precio del producto: ";
cin >> [Link];
inventario.push_back(p); // agregar producto al inventario
cout << "Producto agregado al inventario." << endl;
}
void eliminarProducto() {
string nombre;
cout << "Ingrese el nombre del producto a eliminar: ";
cin >> nombre;
for (int i = 0; i < [Link](); i++) {
if (inventario[i].nombre == nombre) {
[Link]([Link]() + i); // eliminar producto del inventario
cout << "Producto eliminado del inventario." << endl;
return;
cout << "Producto no encontrado en el inventario." << endl;
void mostrarInventario() {
if ([Link]()) {
cout << "El inventario está vacío." << endl;
return;
cout << "Inventario:" << endl;
for (int i = 0; i < [Link](); i++) {
cout << "Nombre: " << inventario[i].nombre << endl;
cout << "Cantidad: " << inventario[i].cantidad << endl;
cout << "Precio: $" << inventario[i].precio << endl;
cout << endl;
int main() {
int opcion;
do {
cout << "Menu:" << endl;
cout << "1. Agregar producto" << endl;
cout << "2. Eliminar producto" << endl;
cout << "3. Mostrar inventario" << endl;
cout << "4. Salir" << endl;
cout << "Ingrese una opción: ";
cin >> opcion;
switch (opcion) {
case 1:
agregarProducto();
break;
case 2:
eliminarProducto();
break;
case 3:
mostrarInventario();
break;
case 4:
cout << "Saliendo del programa." << endl;
break;
default:
cout << "Opción inválida. Intente de nuevo." << endl;
break;
} while (opcion != 4);
return 0;