从键盘上输入一个三行三列矩阵的各个元素的整型值后输出元素平均值

来源:百度知道 编辑:UC知道 时间:2024/05/28 18:40:24

#include <iostream>
using namespace std;

template<class T>
double CreateMatrix(const int y,const int x){
double re=0.0;
T** m=new T*[y];
for(int i0=0;i0!=y;i0++)
m[i0]=new T[x];
for(int i=0;i!=y;i++){
for(int j=0;j!=x;j++){
cout<<"Please input the value at m["<<i+1<<"]["<<j+1<<"]:";
cin>>m[i][j];
cout<<endl;
}
}
cout<<"The Matrix you create:"<<endl;
for(int i1=0;i1!=y;i1++){
for(int j1=0;j1!=x;j1++){
cout<<m[i1][j1]<<'\t';
re+=m[i1][j1];
}
cout<<endl;
}
for(int k=0;k!=y;k++)
delete [] m[k];
delete [] m;
return re/(y*x)*1.0;
}

int main(void){
int x,y;
cout<<"Please input the Height and Width of the Matrix:"<<endl;
cin>

输入一个三行四列的矩阵,求出所有元素的平均数(整形、二维数组) 从命令行输入9个double类型数值,并建立一个三行三列的数组matrix 从命令行输入9个double类型数值,并建立一个三行三列的数组matrix. 用C语言编程~~:输入三阶矩阵,输出该矩阵的转置矩阵。 ASP怎么让三行三列输出? 输入一个字符串输出字符串长度,求一个3*4的矩阵各列元素的平均值,将原矩阵和求出的平均值全部输出 从键盘上输入一个正整数,在屏幕上输出它的每一位数字 Vb编程:输入5*5矩阵,求出每列元素之和,并把最大值的那一列上的个元素和第一列上个元素进行对调。救急! 要用C语言编一个类似五子棋的游戏“只有三行三列的只要谁先下到三个相连的谁就胜出”这应该怎么去编呢 从键盘上输入一个字母,在屏幕输出于其相连的三个字母.