Algorithm Gossip: 稀疏矩阵
来源:互联网 发布:淘宝网阿迪达斯足球鞋 编辑:程序博客网 时间:2024/05/03 19:29
/**************************************** * File Name : arithmetic.c * Creat Data : 2015.2.4* Author : ZY *****************************************/ /*Algorithm Gossip: 稀疏矩阵*//*如果在矩阵中,多数的元素并没有资料,称此矩阵为稀疏矩阵*//*0 0 0 0 0 0 0 3 0 0 0 0 0 0 0 6 0 0 0 0 9 0 0 0 0 0 0 0 12 0 此矩阵为5*6矩阵,非零元素4个,使用阵列第一行记录其行数、列数与非零元素的个数5 6 4阵列的第二行开始,记录行索引、列索引和存储数据1 1 32 3 63 2 94 4 12*/#include <stdio.h>int main(void){int num[5][3] = {{5,6,4},{1,1,3},{2,3,6},{3,2,9},{4,4,12}};int i,j,k = 1;printf("sparse matrix:\n");for(i = 0;i < 5;i++){for(j = 0;j < 3;j++){printf("%4d ",num[i][j]);}printf("\n");}printf("matrix还原:\n");for(i = 0;i < num[0][0];i++){for(j = 0;j < num[0][1];j++){if(k <= num[0][2]&&i == num[k][0]&&j == num[k][1]){printf("%4d",num[k][2]);k++;}else{printf("%4d",0);}}printf("\n");}return 0;}
0 0
- Algorithm Gossip: 稀疏矩阵
- Algorithm Gossip: 多维矩阵转一维矩阵
- Algorithm Gossip: 上三角形,下三角形,对称矩阵
- Algorithm Gossip: 三色棋
- Algorithm Gossip: 三色棋
- Algorithm Gossip: 数字拆解
- Algorithm Gossip:三色棋
- Algorithm Gossip:生命游戏
- Algorithm Gossip: 字串核对
- Algorithm Gossip:长PI
- Algorithm Gossip: 完美数
- Algorithm Gossip: 阿姆斯壮数
- Algorithm Gossip: 得分排行
- Algorithm Gossip (END)
- Algorithm Gossip: 超長整數運算(大數運算)
- Algorithm Gossip: 中序式轉後序式(前序式)
- Algorithm Gossip: 费式数列
- Algorithm Gossip: 费式数列
- Algorithm Gossip: 最大访客数
- Flash动画课堂教学的问题及改进措施
- Linux命令学习:wc
- iOS7.1以后企业应用发布需要HTTPS协议,解决步骤(经典正确版,测试通过版)
- Algorithm Gossip: 约瑟夫问题(Jossphus Problem)
- Algorithm Gossip: 稀疏矩阵
- Leetcode NO.77 Combinations
- Algorithm Gossip: 多维矩阵转一维矩阵
- Algorithm Gossip: 上三角形,下三角形,对称矩阵
- linux达人养成手册,带命令实例解析
- Android中Preference的使用以及监听事件分析
- 向量与矩阵的卷积算法
- html页面绑定代理事件
- MS脑筋急转弯系列1