package Stack;public class LNodeStack {private LNode head;private int top = 0;private final static int SIZE = 100;public LNodeStack() {head=new LNode();}public void push(Student stu) {if (top > SIZE - 1) {System.out.println("此栈已溢出。");return;}LNode temp = new LNode(stu);temp.next = head.next;head.next = temp;++top;}public String pop() {if (top <= 0) {System.out.println("此栈已为空。");return null;}--top;int i=0;for(LNode temp=head.next;temp!=null;temp=temp.next){if(top==i){return temp.stu.name;}i++;}return null;}public void show() {if (top <= 0) {System.out.println("此栈已为空。");return;}for (LNode temp = head.next; temp != null; temp = temp.next) {String name = temp.stu.name;boolean sex = temp.stu.isBoy;System.out.print("姓名:" + name + " ");if (sex) {System.out.println("男");} else {System.out.println("女");}}}}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。