From dd114141f174a695a58aa86b905fd239cd64e1e6 Mon Sep 17 00:00:00 2001 From: luoyang <1822848007@qq.com> Date: Tue, 17 Nov 2020 13:14:45 +0800 Subject: [PATCH] =?UTF-8?q?=E7=AC=AC=E4=BA=8C=E6=AC=A1=E4=BD=9C=E4=B8=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Main.class | Bin 0 -> 541 bytes Main.java | 12 ++++ Stack.class | Bin 0 -> 1118 bytes Stack-pseudocode.java => Stack.java | 88 +++++++++++++++------------- duilie/Main.class | Bin 0 -> 576 bytes duilie/Main.java | 10 ++++ duilie/MyQueue.class | Bin 0 -> 1047 bytes duilie/MyQueue.java | 37 ++++++++++++ duilie2/Main.class | Bin 0 -> 597 bytes duilie2/Main.java | 12 ++++ duilie2/MyQueue.class | Bin 0 -> 1475 bytes duilie2/MyQueue.java | 50 ++++++++++++++++ duilie2/Node.class | Bin 0 -> 424 bytes duilie2/Node.java | 7 +++ lianbiao/LinkedList.class | Bin 0 -> 1492 bytes lianbiao/LinkedList.java | 48 +++++++++++++++ lianbiao/Main.class | Bin 0 -> 611 bytes lianbiao/Main.java | 12 ++++ lianbiao/Node.class | Bin 0 -> 424 bytes lianbiao/Node.java | 7 +++ 20 files changed, 241 insertions(+), 42 deletions(-) create mode 100644 Main.class create mode 100644 Main.java create mode 100644 Stack.class rename Stack-pseudocode.java => Stack.java (52%) mode change 100755 => 100644 create mode 100644 duilie/Main.class create mode 100644 duilie/Main.java create mode 100644 duilie/MyQueue.class create mode 100644 duilie/MyQueue.java create mode 100644 duilie2/Main.class create mode 100644 duilie2/Main.java create mode 100644 duilie2/MyQueue.class create mode 100644 duilie2/MyQueue.java create mode 100644 duilie2/Node.class create mode 100644 duilie2/Node.java create mode 100644 lianbiao/LinkedList.class create mode 100644 lianbiao/LinkedList.java create mode 100644 lianbiao/Main.class create mode 100644 lianbiao/Main.java create mode 100644 lianbiao/Node.class create mode 100644 lianbiao/Node.java diff --git a/Main.class b/Main.class new file mode 100644 index 0000000000000000000000000000000000000000..a91cd38b67c453b1f78d5941e69da1122e074132 GIT binary patch literal 541 zcmY*V+e*Vg6r637rmaz{wbgpJUV2lD;#)-!K@jQ%DuVcw*0si_NoZ5W&(enq3Vwhe zCCyQ8OS6NK~{z71ZI#^Xf}yC%qz5@!lHpC1Iq%j zecQEz1A%C`m)lokyCh}M@uxerr>n1i(Fi{d@1}&~dN~wP5u{c=#{~j1evH7QFTH8^j9%7swb3liUVU zm>^cvJ4D0g-48^rV{eGoEBX*x#ZVy?V|;~P8G^|8MR6h~5`VgR#Hkdeu0~BAX->+4 RD`kF*7I$b;V3M2&(m&E7Ux5Gs literal 0 HcmV?d00001 diff --git a/Main.java b/Main.java new file mode 100644 index 0000000..664a82a --- /dev/null +++ b/Main.java @@ -0,0 +1,12 @@ +class Main{ + public static void main(String[] args) { + Stack s=new Stack(3); + s.push(2); + s.push(4); + s.push(6); + System.out.println(s.pop()); + System.out.println(s.peek()); + //s.push(8); + s.showAll(); + } +} \ No newline at end of file diff --git a/Stack.class b/Stack.class new file mode 100644 index 0000000000000000000000000000000000000000..87cf36f302824ab7ef5437ccb21b28d046460006 GIT binary patch literal 1118 zcmaKs+fEZv6o&sjJxn_c6j};uQ9+BeRay^t1W`~-NKlM5Cg6<&9bs_VnM|h;y!I`O z7hZYejYdkM#s}~fd=q2De@`o-5HDu$J?rqTwf@=d*PkE102srxh8|?&=*F;IPRV5? zjvVqa6f~U1nHWY@6g9+=jiDs>vvN5nm-8~>f{HN}7X>19-&lSopgf)x2>FgHAb1Mb zt>>mdbi%4x{v_XXv-wBdZaEd26LVJ0yw|8MnchQV$)+XjHtMSaon=Y8Yq)K5$d$lQ zE-#U;X|j-7Uv)O7Y&$R$sg<3Ew`|_ABt{GJi)+TZp`#x|I{J{-kwi*IFVZS5>9~w5 z0?8n7e%{5NH$>iU}k{SsEPjoM17?0Z&iWx8S671QIKgE}T~ zT`rS4Zs4YlDVZJ#*aF>uGUu1p%w_*CQ+c!Qn^jKXH0Vgr1;Lh6y3ZOuE15=>tkeN! zYT(KsyT-g+D{)VM<5K9T;kst6A~1STz`mUJOe{FS5A`2+%y(KU2=wOm2g>P#-Y~>F z)x+Bs0>ws(CuShcU6J2}dxTFv4$*#?r%Bos?tO)Ah(cxyN+I)E+d`v1SQ5E0*L6s#`=JoyXhjL%m9 literal 0 HcmV?d00001 diff --git a/Stack-pseudocode.java b/Stack.java old mode 100755 new mode 100644 similarity index 52% rename from Stack-pseudocode.java rename to Stack.java index 567e476..5c897d9 --- a/Stack-pseudocode.java +++ b/Stack.java @@ -1,42 +1,46 @@ -public class Stack { - public int[] stack; - public int top; - private int size; - - Stack(int size){ - // 构建一个长度为size大小的空数组来模拟栈 - this.size = size; - stack = new int[size]; - top = 0; // top永远指向下一个可放入的位置 - } - - - public void push(int item){ - if(top >= size ){ - throw new Exception("StackOverflowError"); - } - - stack[top] = item; - top++; - } - - - public int pop(){ - if(top <=0 ){ - throw new Exception("StackEmpty"); - } - - return stack[top--]; - - } - - public int peek(){ - - if(top <=0 ){ - throw new Exception("StackEmpty"); - } - return stack[top-1]; - } -} - - +public class Stack { + public int[] stack; + public int top; + private int size; + + Stack(int size){ + this.size = size; + stack = new int[size]; + top = -1; + } + + + public void push(int item){ + if(top >= size ){ + System.out.println("StackOverflowError"); + } + + stack[++top] = item; + } + + + public int pop(){ + if(top <=0 ){ + System.out.println("StackEmpty"); + } + + return stack[top--]; + + } + + public int peek(){ + + if(top <=0 ){ + System.out.println("StackEmpty"); + } + return stack[top-1]; + } + + public void showAll(){ + for(int i=top;i>=0;i--){ + System.out.print(" "+stack[i]); + } + } +} + + diff --git a/duilie/Main.class b/duilie/Main.class new file mode 100644 index 0000000000000000000000000000000000000000..8d3b9141b9c6358b9ce4af3f890bb386b61f8b51 GIT binary patch literal 576 zcmY*W+e*Vg5Ix(b-8RN+t@nD@rY+bP-xOa2p-^vByx@bRy3}ZzNKJ%(mOfNa@B{oP z@oW??fy~U#%sF#r_xkEw8=k*)s!Kr$V->Npkj_bEJG|+4W zQRhvAn*}UNELm8_iiK4aC2R{NlsQYo1%`eH z?Kf}KWyp$Mi-*Nz7YEV(H79=`0?&)LsQp7Wy7!@Kvk*kY=fA|eLG^&jL+V#fd*g@W zPN`cq*`+@_*8EVlREJHuSkHefSG&_p9`)w!Kd>*wyc#Z><%{Sq!JpRwfqq5>dO@Em zKSMk+5E!6M$4TBH1~J4~x1J&ygY8!&&g3(a^@`DhQAuf&)~1Kl$rIA_vWLts+bksU ZNwOJaPa#MC3FZpOpvbJiFzX47d;*~ha9{uc literal 0 HcmV?d00001 diff --git a/duilie/Main.java b/duilie/Main.java new file mode 100644 index 0000000..fa311a9 --- /dev/null +++ b/duilie/Main.java @@ -0,0 +1,10 @@ +class Main{ + public static void main(String[] args) { + MyQueue m=new MyQueue(4); + m.Queue_Push(1); + m.Queue_Push(2); + m.Queue_Push(3); + m.Queue_Poll(); + System.out.println(m.Queue_peek()); + } +} \ No newline at end of file diff --git a/duilie/MyQueue.class b/duilie/MyQueue.class new file mode 100644 index 0000000000000000000000000000000000000000..83eb72aa14dd86ac28ecb66fb69386823e63cc04 GIT binary patch literal 1047 zcmZuv+fEZv6kTVg?a=99p~$s>MFrccEht_h#Kf3rNI)Oxl>j zwIuQ=bfIYDI&N6FX`v)wxc67!z#g%A0jUns0G zJ#JLlPA_`Cd=}N$Ww7e5*VwV2M>3MHSEAOIKzAi{H+GiXramOz@p)6q9fAIQVR75t zb;~u^-z+cqq1=?g-0{##qgEr2e1U9IoxOqQlOKB|VOJVaupys#3fNiN(<3Fd&_M>{ z4jgnlxPY{S9u<0#worC3jTsBK9NfmNKxTDI=H4mNIj@zI^=7zd;f{m5xF=wBmJ0No z@LXQsmK!9|d(!Gq=LfrPEt1P`1qNu;x#CW3s_eBwS*M&v#C`qkaj#KcQ7S88Al*9M z=+ii7+eB)rp_;E;JcYxrJb!bpu!afVdWt_q42Cj-m7%=QnRe(*N0{S$GU$WAMOIHa zXE0}rKOu_QKlTBPqIm#Qg_sKQZ#*V0;|LOr7D2iQmZZ-%`ziJvP7E9`ZE708OmUyv z_7Tf27gbWPhq3A>SmtLWRVVgFp}g2fTvZy%&`=q!02SEeJVl^s-sd1Y{V-lx7&@X1 zgPDJ_jsnAE(UvqxL4u>*3XYFi`h~<-HrgT*`cUc5Vw6$2@S#Ka5y#^nk@^lR)Ad7B zH0Kp{Q|&rK-Bg6lHuWm0tAT9k3zxM8w7nXnTSJsELYOQ?jN$>tw2&Ok^bxBL|8q5s XVZ1|dSktG3lgnu9nBc%A4VwE8cS*I% literal 0 HcmV?d00001 diff --git a/duilie/MyQueue.java b/duilie/MyQueue.java new file mode 100644 index 0000000..e726979 --- /dev/null +++ b/duilie/MyQueue.java @@ -0,0 +1,37 @@ +public class MyQueue { + private int [] arr; + private int start; + private int end; + private int size; + + MyQueue(int initsize){ + arr=new int[initsize]; + start=0; + end=0; + size=0; + } + public void Queue_Push(int item){ + arr[end]=item; + end=end==arr.length-1?0:end+1; + size++; + } + public Integer Queue_peek(){ + return arr[start]; + } + + public int Queue_Poll() { + if (size == 0) { + System.out.println("The queue is empty"); + } + int tmp = start; + start = start == arr.length - 1 ? 0 : start + 1; + size--; + return arr[tmp]; + } + public void Queue_Print() { + + } + +} + + diff --git a/duilie2/Main.class b/duilie2/Main.class new file mode 100644 index 0000000000000000000000000000000000000000..6e20e3c2142a2e9128fcef8c164c546a25cb2458 GIT binary patch literal 597 zcmY*XT}uK%6g{K6Zra+XT3PmCWot$j^k(!D1cLT~QB)7H<{%rohV2IZta>mg=m+$p zqBAR~EzF(Eopa7TcXob$KfeJSU?+xgBn%{D2qB?DN`*NU=A&3ZT4jqdEFoiH*}#fG z)??@nQ<*x*^<4!{gOjaCMp8D;&>|WaS7AsoYc3gp!bys<`U+iMbcALeT*LB=x zNfBeUj^BNdCyoL~s|4>VoCyCpU zUWzU-HEeWNf0Pd%g#(p)yU`%ZD(7zprG{(?=uh-R*a)-s`s~Rz$Lsh!NcPP;o#MGd z(!aFZrGZFAvTf4JkBnG$J=v69VrBz7|EZiTXxR#QBecF@-V6s;e?@&EF5U(NCYWWo z3-0>%2gDl_-a2C>DAEz8FwI;+9a0r}{|lj;4}>cPtq1M8pa(G$#2)lQe?{J5Fdge5 jI+V>(5C~%o8YOik*eDG?0#>p-%hBZ?eG1GF7sBixY2OK%fb7(LgIj6IpeiHSoSpae>SJt2=4N(+G$2#=<ZNo6TesJ$a~J>FFB{uh{w;@bWQ)@6gV!Dp2{$#;VS6j z<~gfN3aNA^d)ZlaMvG2qX>_XO=_OqyxoD;8mOSd9VCKuU>Y_gD%4jRM<~JXaA`83l zk%bTNp@lwy9oWfJ6S(w8`3mMExIdwD| zBo(^08qF+R){CA(_m-=%E(=zjVolHdq|i&b-YG~b-Q*5>jr*5W(!a86)1ds?il>)( zH{}`wsi4d)kIsssTt_?06nL9Yqt#6!zU)Q+Vw&a!A_VhXzj?AL+F--?<5ViT#7iH3 z7ulwY7Ewv2CI9WP_vFXCa*(Ca)AE2CwY=(H{;Ys7Lh?L#3dsxcEguPO8!5FPH=&&ClatB7_E+XOkbcFnJ znFh4uV`3Dc_7jr54+BIQe}jF)v@=2Vp#2Qd`5lkZwgE%9&>bQjd!EfBKduw*H)Z4) z4j))Y%qFxXv1KsdhRJg$$tS2x7x(T)noHT}!C|B@LGL6L%TX=i7^Vv3Hn=I!oVXYm zu literal 0 HcmV?d00001 diff --git a/duilie2/MyQueue.java b/duilie2/MyQueue.java new file mode 100644 index 0000000..2d5de13 --- /dev/null +++ b/duilie2/MyQueue.java @@ -0,0 +1,50 @@ +public class MyQueue{ + private Node head; + private Node rear; + private int size; + + public MyQueue(){ + head=null; + rear=null; + } + public boolean isempty(){ + return size==0? true:false; + } + public boolean Queue_add(int item){ + if(size==0){ + head=new Node(item); + rear=head; + size++; + return true; + }else{ + Node tep=new Node(item); + rear.next=tep; + rear=tep; + size++; + return true; + } + } + + public void Queue_del(){ + if(isempty()){ + System.out.println("队列为空"); + } + head=head.next; + size--; + } + + public Integer Queue_Len(){ + return size; + } + public void print() { + Node temp = this.head; + while(temp.next != null){ + System.out.print(temp.item + " -> "); + temp = temp.next; + } + System.out.println(temp.item); + } + +} + + diff --git a/duilie2/Node.class b/duilie2/Node.class new file mode 100644 index 0000000000000000000000000000000000000000..a383363383e004072772b0293411ecf05b408603 GIT binary patch literal 424 zcmZWlyH3ME5S+6e8#^WjLwHtnj*&AhoM?CI;LO3ffTe1=6bQ3<{+jm}c{%Gp7jrqS z9|YWynw5FIuB3oD95g*byZ(B1#7LO>WvO33#K`x|+%-r3GC5p&Pw}k9}PD@X+>Q!{Jcf5;*w3 zAa{y-6I}5cEuP4r5f6dAZRXNb{ + E item; + Node next=null; + Node(E item){ + this.item=item; + } +} \ No newline at end of file diff --git a/lianbiao/LinkedList.class b/lianbiao/LinkedList.class new file mode 100644 index 0000000000000000000000000000000000000000..b5514c6f90f98a052959944abf149aa136c08e59 GIT binary patch literal 1492 zcmaJ>*-{%v6g{nNG-3cFHajd<;sm5&^Og-TPHbZvXIK*1*gPczYU43tq#8zK`INln zC4Nm(AX0Hv9`led$j78&pF0vrva3?6Iz4^+-g8f%xud`T`{Pdl*RhqsFlJ2*VNT$( zz!ib3Ca&Rn8Xsox5k5BXNd}){J_8dACSg(FhJmFFdN3<+GmXz={aoOdRNWT1V_@09 zU4_Im?Uoc$&RV6U7q}0!8z{uXN>xFvFmT}gpqa4f`ChoheSW2|$>lcl6?z@d*K4)? zZ5=#xx66!VilMu+_w`2Y;F&^qv{`kl%|o+!DC7hAg7e%xbmz*hzdN_S{ao*a6mVLv z^`1hq8hCz4Ir+jSFRNe{y|VVB&3yEu%qvKqEIyN>5}6egtH>R z!Z`94&f|iGcLYW-YGDkc2JTt751NpTbgv)k;Ay$??Q#%Q0s{{$d;y16h;;^5Ev#W( z$Tlo|DLh}Hs4(2RV=?4yc5l_Za!Cgk9^w&;b2CdhdET_}7*8xr!V%sLif-vtIM;wypMT2vTmfs(sGoOuM90 zj<$*pOWCs{|MUv~lb;SNjjT84v000E`OyvYn@k`k6T+vM3<*~ya}w=2DqNF{jN>9P z$K5jXVq7oSCs4LJMob`X$B&V)M~;#Fm4}M-AYF=Rutl0*ugUK;gMM_eoyCmz&M1FI zoIl{PeMF8UB!5EJZ%Ad0I?@vQ5u-0*ZjJno%n7z$_;CG=%|N#vuQJhH#Uv+@nN?r<-)*5-XC3_g_3u&F|v_ zVveC3RIIp;+0yg~mS~Dvmc)oC*8K|;8dmf~7aU{farO}}C(fvH+zFN3l}v3_sVIJl zIEg$l$E-s#iT?|d?M$)rUzns@FVVAgf?fu?>o}L~t0P-Se;oso;=FkE4|5uagDpcE nZ)k!SoTN2*{t7f=3iFtbE^Z?BFOmidHhbFa8sp(~w9dQ+w;wOW literal 0 HcmV?d00001 diff --git a/lianbiao/LinkedList.java b/lianbiao/LinkedList.java new file mode 100644 index 0000000..73a23a4 --- /dev/null +++ b/lianbiao/LinkedList.java @@ -0,0 +1,48 @@ +public class LinkedList { + private Node head; + private Node rear; + public int top; + private int size; + + public LinkedList(int size){ + head=null; + rear=null; + top=0; + this.size=size; + } + public void Stack_Push(int item){ + if(top >= size ){ + System.out.println("StackOverflowError"); + } + if(top==0){ + Node tep=new Node(item); + head=tep; + rear=tep; + }else{ + Node tep=new Node(item); + tep.next=head; + head=tep; + } + top++; + } + public Object Stack_Pop(){ + head=head.next; + top--; + return head.item; + } + + public Object Stack_Peek(){ + return head.item; + } + public void print() { + Node temp = this.head; + while(temp.next != null){ + System.out.print(temp.item + " -> "); + temp = temp.next; + } + System.out.println(temp.item); + } + +} + + diff --git a/lianbiao/Main.class b/lianbiao/Main.class new file mode 100644 index 0000000000000000000000000000000000000000..f7072ea787e75c76965a37341ac461c4dfc53d53 GIT binary patch literal 611 zcmZWm+e*Vg6r637uB}n4wchL9HnnOI)EC7UK@jQ%DuVbRX}f58Nu*5$KT97J6#M`` zN}O#Tv>3?jPgZ{F1gga|`CW?BVPe-WUNCOJ(8_7; zGi5pK_8$bs?fjo}g<~j5^+xx13djfT(`2-?{lDvPFr^v-W>1bq=-;EC2wz?c1cu2n zTm@Hi{SD%ogx61u^@>c1Bu2@#)I+q_y!U~~b?gn%Qo(qIQ7|>cG)Te=%)%@9DML0u l#zOqpJ4;v4D-MIcCQ_U>1<5D_$g#T3sJjd+Fh*SjsUJWab};|| literal 0 HcmV?d00001 diff --git a/lianbiao/Main.java b/lianbiao/Main.java new file mode 100644 index 0000000..3598720 --- /dev/null +++ b/lianbiao/Main.java @@ -0,0 +1,12 @@ +class Main{ + public static void main(String[] args) { + LinkedList ll = new LinkedList(3); + ll.Stack_Push(1); + ll.Stack_Push(2); + ll.Stack_Push(3); + ll.Stack_Push(4); + System.out.println(ll.Stack_Pop()); + System.out.println(ll.Stack_Peek()); + ll.print(); + } +} \ No newline at end of file diff --git a/lianbiao/Node.class b/lianbiao/Node.class new file mode 100644 index 0000000000000000000000000000000000000000..a383363383e004072772b0293411ecf05b408603 GIT binary patch literal 424 zcmZWlyH3ME5S+6e8#^WjLwHtnj*&AhoM?CI;LO3ffTe1=6bQ3<{+jm}c{%Gp7jrqS z9|YWynw5FIuB3oD95g*byZ(B1#7LO>WvO33#K`x|+%-r3GC5p&Pw}k9}PD@X+>Q!{Jcf5;*w3 zAa{y-6I}5cEuP4r5f6dAZRXNb{ + E item; + Node next=null; + Node(E item){ + this.item=item; + } +} \ No newline at end of file -- Gitee