java 需要编译 需要class 或enum 什么意思?帮忙找下错误
publicclassLkQueue{Nodefront,rear;publicLkQueue(){initiate();}privatevoidinitiate(){f...
public class LkQueue {
Node front,rear;
public LkQueue(){
initiate();
}
private void initiate(){
front=rear=null;
}
public void append(int obj){
Node newNode=new Node(obj,null);
if(rear!=null)
rear.next=newNode;
rear=newNode;
if(front==null)
front=rear;
}
public int delete(){
int obj=front.element;
front=front.next;
if(front==null)
rear=null;
return obj;
}
public boolean notEmpty(){
return front!=null;
}
public int count(){
Node p=front;
int n=0;
while(p!=null){
n++;
p=p.next;
}
return n;
}
}
public class exam_Queue{
public int revse(int x){
LkQueue q=new LkQueue();
int n;
while(x>0){
q.append(x%10);
x=x/10;
}
while(q.notEmpty())
n=n*10+q.delete();
return n;
}
}
public boolean Earr(int x){
return reverse(x)==x;
}
public static void main(String args[]){
int m,n;
int a[]={12,23,31,47,47,31,23,12};
m=21345;
n=revse(m);
System.out.println(m);
if(Earr(a[],a[].length)) /*调用Earr函数*/
System.out.println("Yes");
else
System.out.println("Not");
}
}
public class Node
{
int element;
Node next;
Node(Node nextval)
{
next=nextval;
}
Node(int obj,Node nextval)
{
element=obj;
next=nextval;
}
public Node GetNext()
{
return next;
}
public void SetNext(Node nextval)
{
next=nextval;
}
public int GetElement()
{
return element;
}
public void SetElement(int obj)
{
element=obj;
}
} 展开
Node front,rear;
public LkQueue(){
initiate();
}
private void initiate(){
front=rear=null;
}
public void append(int obj){
Node newNode=new Node(obj,null);
if(rear!=null)
rear.next=newNode;
rear=newNode;
if(front==null)
front=rear;
}
public int delete(){
int obj=front.element;
front=front.next;
if(front==null)
rear=null;
return obj;
}
public boolean notEmpty(){
return front!=null;
}
public int count(){
Node p=front;
int n=0;
while(p!=null){
n++;
p=p.next;
}
return n;
}
}
public class exam_Queue{
public int revse(int x){
LkQueue q=new LkQueue();
int n;
while(x>0){
q.append(x%10);
x=x/10;
}
while(q.notEmpty())
n=n*10+q.delete();
return n;
}
}
public boolean Earr(int x){
return reverse(x)==x;
}
public static void main(String args[]){
int m,n;
int a[]={12,23,31,47,47,31,23,12};
m=21345;
n=revse(m);
System.out.println(m);
if(Earr(a[],a[].length)) /*调用Earr函数*/
System.out.println("Yes");
else
System.out.println("Not");
}
}
public class Node
{
int element;
Node next;
Node(Node nextval)
{
next=nextval;
}
Node(int obj,Node nextval)
{
element=obj;
next=nextval;
}
public Node GetNext()
{
return next;
}
public void SetNext(Node nextval)
{
next=nextval;
}
public int GetElement()
{
return element;
}
public void SetElement(int obj)
{
element=obj;
}
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询