栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > C/C++/C#

数据结构:矩阵的转置和查找元素

C/C++/C# 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

数据结构:矩阵的转置和查找元素

关于C++方面的数据结构中的矩阵转置方面的代码

#include
using namespace std;

typedef struct{
	int i,j;  //非零元素的行下标和列下标 
	int e;    //非零元素 
}node; 

typedef struct{
	int mu,nu,tu;//矩阵的行数、列数、和非零元素个数 
	node data[10][10];  //行数最大为10,列数最大为10 
}TSMatrix;

bool Creat_Matrix(TSMatrix &a,int Row_num,int Line_num){  //创建矩阵,行数为 Row_num,列数为Line_num
	if(Row_num>10||Line_num>10){
		cout<<"创建失败";
		return false;
	}
	else{
	a.mu=Row_num;a.nu=Line_num; 
	for(int row=1;row<=a.mu;row++){
		for(int line=1;line<=a.nu;line++){
			a.data[row][line].i=row;
			a.data[row][line].j=line;
		}
	}
		return true;
	}

}

void In_Matrix(TSMatrix &a){  //在矩阵中输入元素 
		cout<<"请输入矩阵元素";
		for(int row=1;row<=a.mu;row++){
		for(int line=1;line<=a.nu;line++){
			cin>>a.data[row][line].e;
		}
	}
}

void Out_Matrix(TSMatrix a){  //输出矩阵 
	for(int row=1;row<=a.mu;row++){
		for(int line=1;line<=a.nu;line++){
			cout<>row_num>>line_num;
	if(Creat_Matrix(a,row_num,line_num)==false)return 0;  //判断是否创建矩阵成功,失败就结束程序 
	In_Matrix(a);
	cout<<"矩阵为"<>select;
	if(select==1){
		cout<<"请输入你想在要查找的元素:";
		cin>>find;
		Find_Element(find,a);
	}
	if(select==2){
		cout<<"请输入你想在要查找的元素:";
		cin>>find;
		Find_Element(find,b);
	}
	TSMatrix c;
	cout<<"转置矩阵和矩阵相乘后的矩阵为:"< 

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/857587.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号