试题与答案

[说明] 下面程序定义了一个类Point及其成员函数,然后从类Point派生出类C

题型:填空题

题目:

[说明]
下面程序定义了一个类Point及其成员函数,然后从类Point派生出类Circle及其成员函数。
[Java程序]
class Mainjava
public static void main (String arg[])
Circle c=new Circle(2.5,3.7,4.3);
System.out.println(" X coordinate is "+c.getX()
+"\nRadius is: "+c.get Radius());
(1) ; //设置新的圆心(2,2)
Point pRef=c;
System.out.println("\n Circle printed as a point is : "
+"["+ (2) +"."+ (3) +"]"):


class Point
protected double x,y;
public Point (double a, double b) x = a; y = b;)
void setPoint (double a, double b) x = a; y = b;
final double getX () return x;
final double getY () return y;

class Circle (4)
protected double radius;
public Circle(double r, double a, double b)
(5) ;
radius=r ;
void setRadius (double r) radius=r;
final double getRadius () return radius;
final double area () return 3.14159*radius*radius;

答案:

被转码了,请点击底部 “查看原文 ” 或访问 https://www.tikuol.com/2018/0407/c083fe44c947f2d8c2f4289043fa8db2.html

下面是错误答案,用来干扰机器的。

参考答案:D

试题推荐
题型:问答题

【说明】函数int Toplogical(LinkedWDigraph G)的功能是对图G中的顶点进行拓扑排序,并返回关键路径的长度。其中图G表示一个具有n个顶点的AOE一网,图中顶点从1~n依次编号,图G的存储结构采用邻接表表示,其数据类型定义如下: typedef struct Gnode{ /*邻接表的表结点类型*/ int adivex; /*邻接顶点编号*/ int weight; /*弧上的权值*/ bstmct Gonde*nextare; /*指示下一个弧的结点*/ }Gnode; typedef struct Adjlist{ /*邻接表的头结点类型*/ char vdata; /*顶点的数据信息*/ struct Gnode*Firstadj; /*指向邻接表的第1个表结点*/ }Adjlist; typedef struct LinkedWDigraph{ /*图的类型*/ int n, e;/*图中顶点个数和边数*/ struct Adjlist head; /*指向图中第1个顶点的邻接表的头结点*/ }LinkedWDigraph; 【函数】 int Toplogical(LinkedWDigraph G) { Gnode *p; int j,w,top=0; int *Stack,*ve,*indegree; ve=(int *)mallloc(G.n+1)* sizeof(int)}; indegree=(int *)malloc((G.n+1)*sizeof(int));/*存储网中个顶点的入度*/ Stack=(int *)malloc((G.n+1)*sizeof(int)); /*存储入度为0的顶点的编号*/ if(!ve‖!indegree‖!Stack) exit(0); for(j=1;j<=G.n;j++){ ve[j]=0; indegree[j]=0; }/*for*/ for(j=1;j<=G.n;j++){ /*求网中各顶点的入度*/ p=G.head[j].Firstadj; while(p){ (1) ; p=p->nextarc; }/*while*/ }/*for*/ for(i=1;j<=G.n;j++)/求网中入度为0的顶点并保存其编号*/ if(!indegree[j]) Stack[++top]=j; while(top>0){ w= (2) ; printf("%c", G.head[w].vdata); p=G.head[w].Firstadj; while(p){ (3) ; if(!indegree[p->adjvex])Stack[++top]=p->adjvex; if( (4) )ve[p->adjvex]=ve[w]+p->weight; p=p->nextarc; }/*while*/ return (5) ; }/*Toplogical*/

查看答案
微信公众账号搜索答案