吉林经济技术专修学院:加急!!大家快来看看!!我的数据结构作业(java描述),运行不出结果,大家帮改改吧,谢谢了

来源:百度文库 编辑:杭州交通信息网 时间:2024/05/14 08:41:30
用邻接表存储图,并遍历
//Graph ----adjlist dfs
////////////////////////////////////////////////////////////////////
class stack
{
private final int size=20;
private int[] st;
private int top;
//---------------------------------------------------------------
public stack() // constructor
{
st=new int[size]; //make array
top=-1;
}
//----------------------------------------------------------------
public void push(int j)
{ st[++top]=j;}
//----------------------------------------------------------------
public int pop()
{ return st[top--];}
//-----------------------------------------------------------------
public int peek()
{return st[top];}
//-----------------------------------------------------------------
public boolean isempty()
{ return(top==-1);}
//-----------------------------------------------------------------
}//end class stack
/////////////////////////////////////////////////////////////////////
class person
{
public int label;
public int number;
public boolean wasvisited;
public person next; //next person in personinklist
//------------------------------------------------------------------
public person(int lab,int num)
{
label=lab;
number=num;
wasvisited=false;
}
//------------------------------------------------------------------
}
// end class person
/////////////////////////////////////////////////////////////////////
class personlinklist
{
public person first;
public person last;

//-------------------------------------------------------------------
public personlinklist()
{ first=null;
last=null;
}
public boolean isempty()
{
return first==null;
}

//-------------------------------------------------------------------
public void insert(int lab,int num)
{
person newperson=new person(lab,num);
if(isempty())
first=newperson;
else
last.next=newperson;
last=newperson;
}
//-------------------------------------------------------------------
} // end personlinklist
//////////////////////////////////////////////////////////////////////
还有两个class没写下 在另外两个同名提问里,谢谢!
如果我写的实在垃圾,哪位帮忙写一个也行啊!