Advertisement

Responsive Advertisement

Membuat Matriks Transpose pada CPP/C++

Berikut sintaks cpp untuk membuat matriks transpose:


#include <stdio.h>
#include <conio.h>

void main()
{
    int  matriks[3][4], i, j, index, endix;

    printf ("matriks transpose copas cieeee \n\n\n");
    printf ("masukkan baris matriks : ");
    scanf ("%i", &index);
    printf ("masukkan kolom matriks : ");
    scanf ("%i", &endix);
    printf ("================================ \n\n");

    for(i=0;i<index;i++)
    {
    for(j=0;j<endix;j++)
    {
  

 printf("input data matriks [%i][%i] : ",i+1,j+1);
    scanf("%i",&matriks[i][j]);
    }
    }

    printf("\n matriks \n");
    for(i=0;i<index;i++)
    {
            for(j=0;j<endix;j++)
            printf("%6i",matriks[i][j]);
            printf("\n");
    }
            printf("\n");

    printf ("\n matriks transpose \n");
    for (j=0; j<endix; j++)
    {
            for (i=0; i<index; i++)
      printf ("%6i", matriks[i][j]);
      printf ("\n");
    }
      getch();
}

Post a Comment

0 Comments