TRANPOSE MATRIX
#include <iostream.h>
#include <stdio.h>
#include <conio.h>
int A[10][10], i, j,baris,kolom;
int main()
{
cout << "Operasi transpose Matrix";
do
{
cout << "\nJumlah Baris = "; cin>>baris;
cout << "Jumlah Kolom = "; cin>>kolom;
}
while((baris>10)||(kolom>10));
//Input Matriks A
printf("Masukan Matriks A\n");
printf("------------------\n");
for(i=0;i<baris;i++)
{
for(j=0;j<kolom;j++)
{
printf("[%i][%i]: ",i+1,j+1);
scanf("%i",&A[i][j]);
}
}
printf("\n\n");
//Matriks A
printf("Matriks\n");
printf("------------------\n");
for(i=0;i<baris;i++)
{
for(j=0;j<kolom;j++)
{
printf("%3i",A[i][j]);
}
printf("\n");
}
printf("\n\n");
//Transpose Matriks A
printf("Transpose Matriks\n");
printf("------------------\n");
for(i=0;i<baris;i++)
{
for(j=0;j<kolom;j++)
{
printf("%3i",A[j][i]);
}
printf("\n");
}
printf("\n");
getch();
}
#include <stdio.h>
#include <conio.h>
int A[10][10], i, j,baris,kolom;
int main()
{
cout << "Operasi transpose Matrix";
do
{
cout << "\nJumlah Baris = "; cin>>baris;
cout << "Jumlah Kolom = "; cin>>kolom;
}
while((baris>10)||(kolom>10));
//Input Matriks A
printf("Masukan Matriks A\n");
printf("------------------\n");
for(i=0;i<baris;i++)
{
for(j=0;j<kolom;j++)
{
printf("[%i][%i]: ",i+1,j+1);
scanf("%i",&A[i][j]);
}
}
printf("\n\n");
//Matriks A
printf("Matriks\n");
printf("------------------\n");
for(i=0;i<baris;i++)
{
for(j=0;j<kolom;j++)
{
printf("%3i",A[i][j]);
}
printf("\n");
}
printf("\n\n");
//Transpose Matriks A
printf("Transpose Matriks\n");
printf("------------------\n");
for(i=0;i<baris;i++)
{
for(j=0;j<kolom;j++)
{
printf("%3i",A[j][i]);
}
printf("\n");
}
printf("\n");
getch();
}
Komentar
Posting Komentar