public class test {
public static class Node{
int data;
Node next;
}
public void List_Init(Node node ,int data[]){
Node t=new Node();
t=node;
for(int i=0;inew Node();
p.data=data[i];
p.next=null;
t.next=p;
t=p;
}
}
public void delete_Element(Node head ,int value){
Node p=head;
while(p.next!=null){
Node t=p.next;
if(t.data==value){
p.next=t.next;
break;
}
else
p=p.next;
}
}
public void outPut(Node node ){
for(Node x=node.next;x!=null;x=x.next){
System.out.print(x.data+" ");
}
System.out.println();
}
public static void main(String[] args){
test L=new test();
int[] data ={10,11,222,3,4,1,56,1,21,5,62,6,7,57};
int x=2;
Node node =new Node();
L.List_Init(node, data);
L.outPut(node);
L.delete_Element(node, x);
L.outPut(node);
}
}
看看你的类的定义,肯定是有什么地方写错了,少了符号
public后面没有冒号
根据你的语法,是java代码,不是c++