乱世重典

--得天道之垂青 破地道之迂腐 尽人道灵性 

原创 矩阵转置(C)收藏

新一篇: 编写程序实现n阶(n为奇数)魔方(C) | 旧一篇: 编写程序实现约瑟夫(Josephu)问题(C)

/*编写程序实现用三元组表示的稀疏数组的输入、转置、输出。
>可以直接输入三元组,转置基于三元组进行,输出的结果也为三元组。
>11 12 13
>21 22 23
>31 32 33
>
*/
#include
<stdio.h>
main(){
int m[3][3];
int i,j,t;
for (i=0;i<3;i++){
printf(
"请输入三元组第%d行,中间用","分隔",i+1);
scanf(
"%d,%d,%d",&m[i][0],&m[i][1],&m[i][2]);}
for (i=0;i<3;i++)
for (j=0;j<3;j++)
if(i>j){
    t
=m[i][j];
    m[i][j]
=m[j][i];
    m[j][i]
=t;
}


for (i=0;i<3;i++){
for (j=0;j<3;j++)
printf(
"%d ",m[i][j]);
printf(
" ");
}
getch();
}
 

发表于 @ 2007年03月02日 11:39:00|评论(loading...)|收藏

新一篇: 编写程序实现n阶(n为奇数)魔方(C) | 旧一篇: 编写程序实现约瑟夫(Josephu)问题(C)

评论:没有评论。

发表评论  


当前用户设置只有注册用户才能发表评论。如果你没有登录,请点击登录
Csdn Blog version 3.1a
Copyright © 重典