题目内容

阅读以下说明和Jrdva代码,将应填入 (n) 处的字句写在对应栏内。[说明]在销售系统中常常需要打印销售票据,有时需要在一般的票据基础上打印脚注。这样就需要动态地添加一些额外的职责。如下展示了Decorator(修饰)模式。SalesOrder对象使用一个SalesTicket对象打印销售票据。图6-1显示了各个类间的关系。以下是Java语言实现,能够正确编译通过。[图6-1][Java代码]//Component.java文件public (1) class Component {abstract publ ic void prtTicket();}//salesTicket.java文件public class SalesTicket extends Component{public void prtTicket(){//Sales ticket printing code hereSystem.out.printin("SalesTicket");}}//Decorator.java文件publ ic abstract class Decorator extends Component{public void prtTicket(){if(myComp!=null)myComp.prtTicket();}private (2) myComp;public Decorator(Component myC){myComp=myC;}}//Footer.java文件public class Footer extends Decorator {public Footer(Component myC){(3) ;}public void prtTicket(){(4) ;prtFooter();}publ ic void prtFooter(){//place printing footer code hereSystem.out.println("Footer");}}//salesorder.java文件public class SalesOrder{void prtTicket(){Component myST;myST=new Footer( (5) );//Print Ticket with footers as neededmyST.prtTicket();}} (3)处填()。

查看答案
更多问题

简论清末礼法之争。

Questions 27 to 29 are based on the following news. At the end of the news item, you will be given 15 seconds to answer the questions. Now listen to the news. Who says the trial will begin in Kuala Lumpur on November 2nd

A. The Deputy Prime Minister.
B. Mr. Anwar.
C. A VOA reporter.
D. The High Court judge.

阅读下列函数说明和C代码,将应填入 (n) 处的字句写在对应栏内。[说明]HufTman树又称最优二叉树,是一类带权路径长度最短的树,在编码中应用比较广泛。构造最优二叉树的Huffman算法如下:①根据给定的n各权值{W1,w2,…,wn)构成n棵二叉树的集合F={T1,T2,…,Tn},其中每棵树Ti中只有一个带权为wi的根节点,其左右子树均空。②在F中选取两棵根节点的权值较小的树作为左右子树,构造一棵新的二叉树,置新构造二叉树的根节点的权值为其左右予树根节点的权值之和。③从F中删除这两棵树,同时将新得到的二叉树加入到F中。重复②③,直到F中只剩一棵树为止。函数中使用的预定义符号如下:#define INT MAX 10000#define ENCODING LENGTH 1000typedef enum(none,left_child,right_child) Which;/*标记是左孩子还足右孩子*/typedef char Elemtype;typedef struct TNode{//Huffman树节点Elemtype letter;intweight; //权值int parent; //父节点Which sigh;char *code; //节点对应编码}HTNode,*HuffmanTree;int n;char coding[50];//储存代码[函数]void Select(HuffmanTree HT,int end,int *sl,int *s2)/*在0~END之间,找出最小和次小的两个节点序号,返吲S1、S2*/{int i;int min 1=INT_MAX;int min 2=INT_MAX;for(i=0;i<=end;i++){/*找最小的节点序号*/if(( (1) )&&(HT[i].weight<minl)){*s1=i;min 1=HT[i].weight;}}for(i=0;i<=end;i++){/*找次小节点的序号*/if((HT[i].parent==0)&&( (2) )&&(min 2>HT[i].weight)){*s2=i;min 2=HT[i].weight;}}}void HuffmanTreeCreat(HuffmanTree&HT)/*建立HUFFMAN树*/{int i;int m=2*n-1;int s1,s2;for(i=n;i<m;i++){Select( (3) );HT[s1].parent=i;HT[s2].parent=i;HT[s1].sigh=left child;HT[s2].sigh=right child;HT[i].weight= (4) ;}}void HuffmanTreeEncoding(char sen[],HuffmanTree HT){ /*将句子进行编码*/int i=0;int j;while(sen[i] !=’\0’){for(j=0;j<n;j++){if(HT[j].letter==sen[i])(/*字母吻合则用代码取代*/strcat(coding, (5) );break;}}i++;if (Sen [1]==32) i++;}printf("\n%s",coding);} (5)处填()。

Questions 21 to 23 are based on the following news. At the end of the news item, you will be given 15 seconds to answer the questions. Now listen to the news How long has Burma’s military been in power

A. For more than 30 years.
B. For more than 20 years.
C. For more than 50 years.
D. For more than 40 years.

答案查题题库