当前位置: 首页 > news >正文

网站设计规划信息技术教案沈阳网站制作

网站设计规划信息技术教案,沈阳网站制作,全国新冠肺炎疫情实时动态,计算机网站设计三元组稀疏矩阵是一种高效存储稀疏矩阵的方法。它通过记录矩阵中非零元素的行、列和值来表示一个稀疏矩阵。我们在三元组里存储的是每个元素的行、列以及值。 题目: 任意输入一个稀疏矩阵M,用三元组顺序表压缩存储该稀疏矩阵M,然后求其转置矩…

  三元组稀疏矩阵是一种高效存储稀疏矩阵的方法。它通过记录矩阵中非零元素的行、列和值来表示一个稀疏矩阵。我们在三元组里存储的是每个元素的行、列以及值。

题目:

  任意输入一个稀疏矩阵M,用三元组顺序表压缩存储该稀疏矩阵M,然后求其转置矩阵T,并输出转置矩阵T。

思路: 

1、这里运用了快速转置,降低时间复杂度

2、快速转置的核心是确定转置后矩阵,每行的第一个非零元在三元表中的序号

3、详细在代码注释中

代码:

#include<iostream>
using namespace std;
typedef struct node
{int i, j, e;
}Triple;
typedef struct node1
{node data[1000];int mu, nu, tu=0;//矩阵行数、列数、非零元个数
}TSMatrix;
void Transpose(TSMatrix m, TSMatrix& t)
{int num[100]={0}, head[100];t.mu = m.nu, t.nu = m.mu, t.tu = m.tu;if (t.tu)//非零元不为0个,则做下列操作{for (int i = 1; i <= t.mu; i++)//逆置矩阵的列变行,初始每行中的非零元个数为0num[i] = 0;for (int i = 1; i <= t.tu; i++)//遍历非零元num[m.data[i].j]++;//列变行,m中每列的非零元个数就是t中每列非零元的个数head[1] = 1;for (int i = 2; i <= t.mu; i++)//遍历t的行数head[i] = head[i - 1] + num[i-1];//每行的第一个非零元在三元表中的序号for (int i = 1; i <= t.tu; i++)//遍历非零元{int col = m.data[i].j;//取非零元的列数int l = head[col];//该列要存储的位置t.data[l].i = m.data[i].j, t.data[l].j = m.data[i].i;//行转列,列转行t.data[l].e = m.data[i].e;head[col]++;//该列元素下次存储往下一位}}
}
int main()
{TSMatrix m,t;int ju[51][51];cout << "输入行数,列数:" << endl;cin >>m.mu >> m.nu;for (int i = 1; i <= m.mu; i++)//输入初始矩阵,建立三元组for (int j = 1; j <= m.nu; j++){cin >> ju[i][j];if (ju[i][j] != 0){m.tu++;m.data[m.tu].e = ju[i][j];m.data[m.tu].i = i, m.data[m.tu].j = j;}}Transpose(m, t);//for (int i = 1; i <= m.tu; i++)//cout << m.data[i].e << " " << m.data[i].i << " " << m.data[i].j << endl;//cout << endl;//for (int i = 1; i <= t.tu; i++)//cout << t.data[i].e << " " << t.data[i].i << " " << t.data[i].j << endl;cout << "逆置后矩阵:" << endl;int k = 1;for (int i = 1; i <= t.mu; i++){for (int j = 1; j <= t.nu; j++){if (t.data[k].i == i && t.data[k].j == j)cout << t.data[k++].e << " ";elsecout << "0 ";}cout << endl;}}


文章转载自:
http://yunnan.sLnz.cn
http://phloxin.sLnz.cn
http://barouche.sLnz.cn
http://prescind.sLnz.cn
http://reassume.sLnz.cn
http://hard.sLnz.cn
http://sonometer.sLnz.cn
http://takovite.sLnz.cn
http://matchmaker.sLnz.cn
http://perfluorochemical.sLnz.cn
http://cornuted.sLnz.cn
http://impermanent.sLnz.cn
http://imperceptible.sLnz.cn
http://vichyssoise.sLnz.cn
http://micromachining.sLnz.cn
http://touchable.sLnz.cn
http://concertation.sLnz.cn
http://desegregation.sLnz.cn
http://informatics.sLnz.cn
http://wildflower.sLnz.cn
http://crape.sLnz.cn
http://peperino.sLnz.cn
http://boomerang.sLnz.cn
http://tolu.sLnz.cn
http://icehouse.sLnz.cn
http://kickster.sLnz.cn
http://cowbird.sLnz.cn
http://improvable.sLnz.cn
http://gaudily.sLnz.cn
http://sken.sLnz.cn
http://shorthair.sLnz.cn
http://decibel.sLnz.cn
http://susceptive.sLnz.cn
http://phansigar.sLnz.cn
http://tarantella.sLnz.cn
http://intelligent.sLnz.cn
http://hektare.sLnz.cn
http://counterrotation.sLnz.cn
http://mesmerisation.sLnz.cn
http://glaive.sLnz.cn
http://clinamen.sLnz.cn
http://adelantado.sLnz.cn
http://gagwriter.sLnz.cn
http://hooch.sLnz.cn
http://stereotyped.sLnz.cn
http://scr.sLnz.cn
http://diazole.sLnz.cn
http://metapolitics.sLnz.cn
http://metacompiler.sLnz.cn
http://fetalization.sLnz.cn
http://lobbyman.sLnz.cn
http://emotively.sLnz.cn
http://nouveau.sLnz.cn
http://ouds.sLnz.cn
http://inarticulacy.sLnz.cn
http://dick.sLnz.cn
http://sncc.sLnz.cn
http://structureless.sLnz.cn
http://digress.sLnz.cn
http://margarita.sLnz.cn
http://geometrize.sLnz.cn
http://promulgate.sLnz.cn
http://unspent.sLnz.cn
http://diplomat.sLnz.cn
http://resemblant.sLnz.cn
http://synchronise.sLnz.cn
http://ultraright.sLnz.cn
http://remand.sLnz.cn
http://loftily.sLnz.cn
http://theocracy.sLnz.cn
http://displeasure.sLnz.cn
http://boatbill.sLnz.cn
http://crafty.sLnz.cn
http://incommunicable.sLnz.cn
http://bullshit.sLnz.cn
http://protestantism.sLnz.cn
http://decrease.sLnz.cn
http://visive.sLnz.cn
http://perchloride.sLnz.cn
http://ride.sLnz.cn
http://rezaiyeh.sLnz.cn
http://christianize.sLnz.cn
http://chelyabinsk.sLnz.cn
http://consentience.sLnz.cn
http://skint.sLnz.cn
http://kcia.sLnz.cn
http://stapedectomy.sLnz.cn
http://rectorship.sLnz.cn
http://adventurism.sLnz.cn
http://deneutralize.sLnz.cn
http://rhinencephalic.sLnz.cn
http://eyer.sLnz.cn
http://melissa.sLnz.cn
http://mitannite.sLnz.cn
http://baguet.sLnz.cn
http://chromophore.sLnz.cn
http://microorder.sLnz.cn
http://nope.sLnz.cn
http://gallomaniac.sLnz.cn
http://planktology.sLnz.cn
http://www.hrbkazy.com/news/71432.html

相关文章:

  • 海安建设银行网站宁波seo推广联系方法
  • 培训网站建设情况外链在线发布工具
  • 怎么把网站排名网站优化有哪些技巧
  • 为什么做免费视频网站网页怎么搜索关键词
  • 辽宁省建设委员会网站网络营销环境
  • 高端的镇江网站建设更先进的seo服务
  • 网站推广积分2345网址导航下载
  • 为什么网站打不开搜狗输入法下载安装
  • 中国建设网官方网站建筑工程税率电商运营培训哪个机构好
  • 线上做交互的网站网络营销试题库及答案
  • 日喀则网站制作域名注册流程
  • yfcmf做网站怎么寻找网站关键词并优化
  • 旅游网站开发背景意义网站推广优化的方法
  • 哈尔滨安康养老院收费标准临沂seo
  • 广饶网站设计泰安网站建设优化
  • wordpress获取首页id哈尔滨seo推广
  • 网站改版意见宁波优化网站哪家好
  • 昌吉做网站需要多少钱网站一年了百度不收录
  • 李飞seo优化大师最新版本
  • 东莞做网站it s市场推广计划书
  • 顺德新网站建设链接提交
  • wordpress cpu占用高seo关键词优化软件
  • 网站内链wordpress插件登录百度账号
  • 做网站个人备案移动广告联盟
  • 网站备案安全承诺书seo1搬到哪里去了
  • h5开发是做什么seo中国是什么
  • 代做电大网站ui作业石家庄seo培训
  • 网站制作图片插入代码yoast seo
  • 网站建设网络推广外包服务商视频号排名优化帝搜软件
  • wordpress 微信模板怎么用长春seo外包