Esempio n. 1
0
int main()
{
	Lista<int> mylista;
	int opcion;
	int salida =5;
	while(salida != 0)
	{
	caratula();
	cin >> opcion;
	if(opcion ==1)	
		{
		int datos;
		cout << "cuantos datos quiere añadir" <<endl;
		cin>>datos;	
		for(int i =0;i< datos;i++)
			{cout << "Ingrese el dato "<< i <<endl;
			int n;
			cin>>n;		
			mylista.push(n);}
		cout << "la nueva pila es " <<endl;
		mycola.imprimir();}
	if(opcion ==2)	
		{cout << "el dato es:  ";
		mylista.pop();
		cout << "la pila acumulada es:  " <<endl;
		mylista.imprimir();}
	cout << "Que desea hacer ahora? "<<endl;
	cout << "1: volver al menu    0: salir"<<endl;
	cin >> salida;}}
Esempio n. 2
0
void Lista::Menu()
{
	Lista L;
	int wybor;
	int _element = 0;

	cout << "MENU:" << endl;

	do
	{
		cout << "1 - Dodaj element do stosu " << endl;
		cout << "2 - Usun element ze stosu " << endl;
		cout << "3 - Wyswietl stos " << endl;
		cout << "4 - Sprawdz rozmiar stosu " << endl;
		cout << "5 - Sprawdz czy stos jest pusty " << endl;
		cout << "6 - Wczytaj dane " << endl;
		cout << "7 - Zakoncz program " << endl << endl;
		cout << "Wybor: ";

		cin >> wybor;

		if((wybor > 0) && (wybor < 7))
		{
			switch(wybor)
			{
				case 1: 
					{
						cout << "Wartosc elementu do dodania: " << endl;
						cin >> _element;
						cout << endl;  	
						L.Dodaj_Element(_element);
						break;
					}
				case 2: L.pop();
						break;
				case 3: L.Wyswietl_Elementy();
						break;
				case 4: L.size();
						break;
				case 5: L.empty();
						break;
				case 6: L.Wczytaj_Dane("stos.txt");
						L.Wyswietl_Elementy();
						break;
				case 7: cout << "Zakonczono program..." << endl;
						break;

				default: cerr << "Nieznana opcja!" << endl;
						break;
			}
		} else
			cout << "Wprowadz numer opcji jeszcze raz! " << endl;

	} while (wybor != 6);