-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcodinter2.1.java
66 lines (56 loc) · 933 Bytes
/
codinter2.1.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import java.util.*;
public class Stringtest
{
public static class node //main函数是静态函数,只能调用静态类和静态方法
{public
int data;
node next;
}
public static void dupdelete(node l)
{
node h=l;
node pre=h;
node p=l.next;
while(h.next!=null){
while(p!=null){
if(p.data==h.data){
pre.next=p.next;
p=pre.next;
}
else{
pre=p;
p=p.next;
}
}
h=h.next;
pre=h;
p=pre.next;
}
}
public static void main(String [] argc)
{
node l=new node();
node p=l;
for(int i=1;i<10;i++){
for(int j=0;j<i;j++){
node temp=new node();
temp.data=j;
temp.next=null;
p.next=temp;
p=p.next;
}
}
p=l.next;
while(p!=null){
System.out.print(p.data);
p=p.next;
}
dupdelete(l.next);
System.out.print("\n");
p=l.next;
while(p!=null){
System.out.print(p.data);
p=p.next;
}
}
}