11 Kasım 2016 Cuma

C++ Matrisin Transpozu

#include <iostream>

using namespace std;

int main(){
    int m,n;
    cout << "m (satir sayisi) : ";
    cin >> m;

    cout << "m (sütun sayisi) : ";
    cin >> n;

    int x[m][n];
    int i,j;

    for(i=0;i<m;i++){
        for(j=0;j<n;j++){
            cout << "x[" << i+1 << "][" << j+1 << "] = ";
            cin >> x[i][j];
        }
    }
    for(j=0;j<n;j++){
        for(i=0;i<m;i++){
            cout << x[i][j];
            cout << " ";
        }
        cout << endl;
    }
    return 0;
}

Hiç yorum yok:

Yorum Gönder