java习题答案

更新时间:2023-06-03 03:27:18 阅读: 评论:0

第二章
一、算法设计题学术型硕士和专业型硕士的区别
1、public class ex21 {public static viod main(string[] args)
{int x[]; x=new int[20];
int x[]={2,23,5,15,47}; } }
2、以5题的类定义为基准
public void exchagelink(int id) {
link current=first;
if (impty()) return first==null;
el {first=last; last=current; } }
3、一单链表类为准
public void inrtfirst(int id) { link newlink=new link(id);
if (impty()) last=newlink; =first; first=newlink; } public void inrtlast(int id) { link newlink=new link(id);
if (impty()) first=newlink;
=newlink; last=newlink; }
public void find(int x) {link current=first;
while (current.idata!=x) {if (==null) return null;
el ; } return current; }
public void inrtlink1(int m) { int I=1;
while (I!=m) {
if (!=null) {
link newlink=new link(id);
<=newlink;
I++;
} } }
4、定义link类
class link {
public int idata;
public link next;
public link(int id)
{idata=id;
}
public void displaylink()
{
system.out.print(idata+””);
}
}//end class link
//定义头结点
class firstlastlist
{
private link first;
private link last;
public firstlastlist()
{
first = null;
last=null;
}
public Boolean impty()
{
return (first==null);
}
}
public void inrtfirst(int id)
{
link newlink=new link(id);
if (impty())
last=newlink;
<=first;瘦肉白菜汤
first=newlink;
}
public void inrtlast(int id)
{
link newlink=new link(id);
if (impty())
first=newlink;
el
<=newlink;
last=newlink;
}
5、class link周玄毅马薇薇
{
public int idata;
public link next;
public link previous;
public link(int id)
{idata=id;
}
public void displaylink()
{
system.out.print(idata+””); }
}//end class link
class doublelinklist
{
private link first;
private link last;
public doublelinklist()
{
first=null;
last=null;
}
public Boolean impty()
{
return first==null;
}
public void inrtfirst(int id) {
link newlink=new link(id);
if (impty())
last=newlink;
el
first.previous=newlink; =first;
first=newlink;
}
public void inrtlast(int id) {
link newlink=new link(id);
if (impty())
first=newlink;
el
{
<=newlink;
newlink.previous=last;
}
last=newlink;
}
}
6、
class link
{public long ddata;
public link next;
public link(long dd)
{ddata=dd;}
public void displaylink()
{system.out.print(ddata+””);
}}
class sortlist
{
private link first;
public sortlist()地震资料
{
first=null;}
public Boolean impty()
{return (first==null);}
public void inrt(long key)
{
link newlink=new link(key);
link previous=null;
link current=first;
while (current != null &&key>current.ddata)
{
previous=current;
;}
if (previous==null)
first=newlink;
el
<=newlink;
<=current;
}
public link remove()
{
link temp=first;
;
return temp;
}
民族团结手抄报内容public void displaylist()《水浒传》简介
{
system.out.print(“list(first…>last):”);
link current=first;
while (current!=null)
{
current.displaylink();
<;
}
system.out.print(“”);
}
}
class sortlistapp
{
public static void main(string[] args)
{
sortlist thesortlist=new sortlist(); thesortlist.inrt(20);
thesortlist.inrt(40);
thesortlist.displaylist();
thesortlist.inrt(10);
thesortlist.inrt(30);
thesortlist.inrt(50);
thesortlist.displaylist();
thesortlist.displaylist();
}
}
1、
public void lengthlist()
{
link current=first;
int I=0;
while (!=null)
{
I=I+1;
;}
Return I;
}
2、同6
3、同6
4、public void changelist()
{ link current1=first;
if (!=null)
link ;
if (!=null)
link ;
<=null;
while (current2!=null)
{
<=current1;
考试蒙题技巧current1=current2;
current2=current3;
if (!=null)
;
}
first=current1;
return first;
}
5、public void removelist(link s)
{
毛姆传link current=s;
link previous=null;

本文发布于:2023-06-03 03:27:18,感谢您对本站的认可!

本文链接:https://www.wtabcd.cn/fanwen/fan/82/841781.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:硕士   定义   专业型   表类
相关文章
留言与评论(共有 0 条评论)
   
验证码:
推荐文章
排行榜
Copyright ©2019-2022 Comsenz Inc.Powered by © 专利检索| 网站地图