试题与答案

BTS3012中有4类总线,分别是()、()、()、()

题型:填空题

题目:

BTS3012中有4类总线,分别是()、()、()、()

答案:

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

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

参考答案:错

试题推荐
题型:问答题

请使用VC6或使用[答题]菜单打开考生文件夹proj2下的工程proj2,其中有矩阵基类MatrixBase、矩阵类Matnx和单位阵UnitMatrix的定义,还有mam函数的定义。请在横线处填写适当的代码并删除横线,以实现上述类定义。此程序的正确输出结果应为:
1 2 3 4 5
2 3 4 5 6
3 4 5 6 7
1 0 0 0 0 0
0 1 0 0 0 0
0 0 1 0 0 0
0 0 0 1 0 0
0 0 0 0 1 0
0 0 0 0 0 1
注意:只能在横线处填写适当的代码,不要改动程序中的其他内容,也不要删除或移动“//****found****”。
#include<iostream>
using namespace std;
//矩阵基础类,一个抽象类
class MatrixBase
int rows,cols;
public:
MatrixBase(int rows,int cols):rows(rows),cols(cols)
int getRows()constreturn rows;
//矩阵行数
int gatCols()constreturn cols;
//矩阵列数
virtual double getElement(int r,int c)const=0;//取第i个元素的值
void show() const
//分行显示矩阵中所有元素
for(int i=0;i<rows;i++)
cout<<endl;
for(int j=0;j<cols;j++)
//**********found**********
COUt<<______<<" ";


;
//矩阵类
class Matrix:public MatrixBase
double*val;
public:
//**********found**********
Matrix(int rows,int cols,double m[]=NuLL):______
//**********found**********
val=______;
for(int i=0;i<rows* cols;i++)
val[i]=(m==NuLL0.0:m[i]);

~Matrix()delete[]val;
double getElement(int r,int c)constreturn val[r* getCols()+c];
;
//单位阵(主对角线元素都是1,其余元素都是0的方阵)类
class UnitMatrix: public MatrixBase
public:
UnitMatrix(int rows):MatrixBase(rows,rows)
//单位阵行数列数相同
double getElement(int r,int c)
const
//**********found**********
if(______)return 1.0;
return 0.0;

;
int main()
MatrixBase*m;
double d[][5]=1,2,3,4,5,2,3,4,5,6,3,4,5,6,7;
m=new Matrix(3,5,(double*)d);
m->show();
delete m;
cout<<endl;
m=new UnitMatrix(6);
m->show();
delete m;
return 0;

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