小男孩‘自慰网亚洲一区二区,亚洲一级在线播放毛片,亚洲中文字幕av每天更新,黄aⅴ永久免费无码,91成人午夜在线精品,色网站免费在线观看,亚洲欧洲wwwww在线观看

分享

C語(yǔ)言實(shí)現(xiàn)矩陣轉(zhuǎn)置

 融水公子 2019-07-10
表白:黑白圣堂血天使,天劍鬼刀阿修羅。 
講解對(duì)象:
/C語(yǔ)言實(shí)現(xiàn)矩陣轉(zhuǎn)置
作者:融水公子 rsgz
===



1隨機(jī)函數(shù)生成矩陣
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
int main(){
    int i,j;
    int a[5][3];
    printf("生成矩陣:\n");
    //srand(time(NULL));
    for(i=0;i<5;i++){
        for(j=0;j<3;j++){
            a[i][j]=rand()%20;
        }
    }
    for(i=0;i<5;i++){
        for(j=0;j<3;j++){
            printf("%d ",a[i][j]);
        }
        printf("\n");
    }
    return 0;
}




2轉(zhuǎn)置矩陣
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
int main(){
    int i,j;
    int a[5][3]={{1,2,3},
                {4,5,6},
                {7,8,9},
                {10,11,12},
                {13,14,15}};
    int b[3][5];
    printf("原來(lái)矩陣:\n");
    for(i=0;i<5;i++){
        for(j=0;j<3;j++){
            printf("%d\t",a[i][j]);//輸出矩陣
        }
        printf("\n");
    }
    printf("轉(zhuǎn)置矩陣:\n");
    for(i=0;i<5;i++){
        for(j=0;j<3;j++){
            b[j][i]=a[i][j];//轉(zhuǎn)置矩陣
        }
    }
    for(i=0;i<3;i++){
        for(j=0;j<5;j++){
            printf("%d\t",b[i][j]);//輸出矩陣
        }
        printf("\n");
    }
    return 0;
}

原來(lái)矩陣:
1	2	3	
4	5	6	
7	8	9	
10	11	12	
13	14	15	

轉(zhuǎn)置矩陣:
1	4	7	10	13	
2	5	8	11	14	
3	6	9	12	15
=== 
公眾號(hào):不浪仙人
謝謝大家的支持!可以點(diǎn)擊我的頭像,進(jìn)入我的空間瀏覽更多文章呢。建議大家360doc[www.ahfyzs.com]注冊(cè)一個(gè)賬號(hào)登錄,里面真的有很多優(yōu)秀的文章,歡迎大家的到來(lái)。
---

    轉(zhuǎn)藏 分享 獻(xiàn)花(0

    0條評(píng)論

    發(fā)表

    請(qǐng)遵守用戶 評(píng)論公約

    類似文章 更多