问答题
阅读以下说明,回答问题1和问题2,将解答写在对应栏内。
【说明】
一个野生动物园,有如下动物:老虎、豹、狼、丹顶鹤、鹦鹉、天鹅、金鱼、热带鱼、鳄鱼等等。
【问题2】
UML规定类图中类之间的关系有关联、聚集、继承,请说明它们的含义和之间的区别。
【参考答案】
关联是类之间的语义联系,代表类的实例(对象)之间的一组连接。 聚集是一种特殊的二元关联,它指出类间的“整体—部分”关系,......
(↓↓↓ 点击下方‘点击查看答案’看完整答案 ↓↓↓)
点击查看答案
<上一题
目录
下一题>
热门
试题
问答题
【说明】本程序ExceptionTester实现功能:读入两个整数,第1个数除以第2个数,之后输出。若第2个数为0,则自动进行异常处理。程序如下:(1) ;public class ExceptionTester{public static void main(String args[]){int result;int number[]=new int[2];boolean valid;for(int i=0;i<2;i++){valid= (2) ;while(!valid){try{System.out.println( Enter number +(i+1));number[i]=Integer.valueOf(Keyboard.getString()).intValue();valid=true;}catch(NumberFormatExceptione){System.out.println( Invalid integer entered.Please try again. );}}}by{result=number[0] number[1];System.out.print(number[0]+ +number[1]+ = +result);}catch( (3) ){System.out.println( Second number is 0,cannot do division! );}}}其中,Keyboard类的声明为:impon java.io.*;public class Keyboard{static BufferedReader inputStream=new (4) (new InputStreamReader(System.in));public static int getInteger(){try{return(Integer,valueOf(inputStream.readLlne().trim()).intValue());}catch(Exceptione){e.printStackTrace();return 0;}}public (5) {by{return(inputStream.readLine());} catch(IOExceptione){return 0 ;}}}
点击查看答案
问答题
【说明】 应用Prim算法求解连通网络的最小生成树问题。请阅读程序后填空。const int MaxInt=INT MAX; INT MAX的值在<limits.h>中const int n=6; 图的顶点数,应由用户定义typedef int AdjMatrix[n][n]; 用二维数组作为邻接矩阵表示typedef struct{ 生成树的边结点int fromVex,to Vex; 边的起点与终点int weight; 边上的权值}TreeEdSenode;typedef TreeEdgeNode MST[n-1]; 最小生成树定义void PrimMST (AdjMatrix G,MST T,int rt){ 从顶点rt出发构造图G的最小生成树T,rt成为树的根结点TreeEdgeNode e; int i,k=0,min,minpos,v;for(i=0;i<n;i++) 初始化最小生成树Tif(i!=rt){T[k].fromVex=rt;(1) ;T[k++].weight=G[rt][i];}for(k=0;k<n-1;k++){ 依次求MST的候选边(2) ;for(i=k;i<n-1;i++) 八遍历当前候选边集合if(T[i].weight<min) 选具有最小权值的候选边{min=T[i].weight; (3) ;}if(min==MaxInt) 图不连通,出错处理{cerr<<“Graph is disconnected!”<<endl; exit(1);}e=T[minpos];T[minpos]=T[k]; (4) ;v=T[k].to Vex;for(i=k+1;i<n-1;i++) 修改候选边集合if(G[v][T[i].to Vex]<T[i].weight){T[i].weight=G[v][T[i].toVex];(5) ;}}}
点击查看答案
相关试题
【问题3】 指出在哪些图中遗漏了哪些数据...
【问题3】 指出每个关系模式的候选码。
【问题2】 指出哪张图中的哪些文件不必画出。
【问题2】 将该E-R图转换为关系模型。