📄 b0af66852419001e1cd0d3cf7376f2a4
字号:
class CStiva extends CLista
{
public CStiva()
{
super();
System.out.println("\n\n\nSe apeleaza constructorutorul CDeriv_stiva pentru obiect la adresa:");
System.out.println(this);
super.CLista();
}
public void push( int a )
{
inserare_sfarsit( a );
}
public boolean pop()
{
if (CStiva::isEmpty()==true)
printf("\n\n\n\tStiva este goala!");
else
{
printf("%d",CStiva::peek());
return CLista::stergere_sfarsit();
}
}
// public boolean isEmpty()
{
// if( IsEmpty() == true )
// return true;
// return false;
// }
public void peek()
{
Lista p;
if( p == null )
System.out.println("\n\nStiva este goala!");
else
{
System.out.println( p.nVal);
System.out.println( "\n");
}
}
public boolean afis()
{
return afisare();
}
public static void meniu()
{
System.out.println("\n\n\n1.Push\n2.Pop\n3.IsEmpty\n4.Peek\n5.Afisare\n0.Iesire\n\n\nIntroduceti optiunea: ");
}
public static void main( String args[] )
{
int i = 0;
CDeriv_stiva stiva = new CDeriv_stiva();
Citire cit = new Citire();
meniu();
i = cit.getInteger();
while( i != 0 )
{
switch ( i )
{
case 1:
{
int a , b;
String c;
System.out.println("\n\nDati varsta: ");
a = cit.getInteger();
System.out.println("\n\nDati cheia: ");
b = cit.getInteger();
System.out.println("\n\nDati numele: ");
c = cit.getLine();
stiva.push( a , b , c );
System.out.println("\nElement adaugat\n");
meniu();
}break;
case 2:
{
if( stiva.pop() == true )
System.out.println("\nElement sters");
else
System.out.println("\nStiva este goala!!\n");
//system("cls");
meniu();
}break;
case 3:
{
if( stiva.isEmpty() == true )
System.out.println("\nStiva este goala!\n");
else
System.out.println("\nStiva nu este goala!\n");
meniu();
}break;
case 4:
{
stiva.peek();
meniu();
}break;
case 5:
{
if( stiva.afis() == false )
System.out.println("Stiva este goala!");
// system("cls");
meniu();
}break;
}
i = cit.getInteger();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -