求Visual C++高手速度帮解决下面2个题目 十分感谢

来源:百度知道 编辑:UC知道 时间:2024/05/28 15:42:50
完成下面的填空题目 只在横线上修改
(8)要求输出结果
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
#include<iostream>
using namespace std;
//矩阵基础类,一个抽象类
class MatrixBase{
int rows, cols;
public:
MatrixBase(int rows, int cols): rows(rows), cols(cols){}
int getRows()const{ return rows; } //矩阵行数
int getCols()const{ return 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 co

for(int i=0; i<rows; i++){
cout<<endl;
for(int j=0; j<cols; j++)
//**********found**********
cout<<____________________________<<" "; //i+j+1
}
}
};

void Triangle::Show() // 输出字符组成的三角形
{
for (int i = 1; i <= _rows; i++) {
//********found********
for (int j = 1; j <= __________; j++) //i
cout << _ch;
cout << endl;
}
}

void Rectangle::Show() // 输出字符组成的矩形
{
//********found********
for (int i = 1; i <= __________; i++) { //_rows
//********found********
for (int j = 1; j <= __________; j++) //_cols
cout << _ch;
cout << endl;
}
}