Program Transpose Matrik dengan Bahasa C


Beberapa jenis matriks berdasarkan ordo dan elemen-elemen matriks,salah satu satunya Transpos matriks A. Transpos matriks A atau adalah sebuah matriks yang disusun dengan cara menuliskan baris ke-i matriks A menjadi kolom ke-i dan sebaliknya, menuliskan kolom ke-j matriks A menjadi baris ke-j.
Program Transpos matrik
   1:  #include <stdio.h>
   2:  #include <conio.h>
   3:  
   4:  
   5:  void main()
   6:  {
   7:  int j,i,a[2][2];
   8:  a[0][0]=1;
   9:  a[0][1]=2;
  10:  a[1][0]=5;
  11:  a[1][1]=6;
  12:  
  13:  for (i=0; i<2; i++){
  14:      for(j=0;j<2;j++){
  15:  
  16:      printf(" %d",a[i][j]);
  17:  
  18:      }
  19:      printf("\n");
  20:  }
  21:  
  22:  printf("Transpose \n");
  23:  
  24:  for (i=0; i<2; i++){
  25:      for(j=0;j<2;j++){
  26:  
  27:      printf(" %d",a[j][i]);
  28:  
  29:      }
  30:      printf("\n");
  31:  
  32:  }
  33:      getch();
  34:  }
  35:  

Program kedua

   1:  #include <stdio.h>
   2:  #include <conio.h>
   3:  
   4:  
   5:  void main()
   6:  {
   7:  int j,i,a[2][2],b[2][2];
   8:  a[0][0]=1;
   9:  a[0][1]=2;
  10:  a[1][0]=5;
  11:  a[1][1]=6;
  12:  
  13:  for (i=0; i<2; i++){
  14:      for(j=0;j<2;j++){
  15:  
  16:      b[j][i]=a[i][j];
  17:  
  18:      }
  19:      printf("\n");
  20:  }
  21:  
  22:  
  23:  for (i=0; i<2; i++){
  24:      for(j=0;j<2;j++){
  25:  
  26:      printf(" %d",a[i][j]);
  27:  
  28:      }
  29:      printf("\n");
  30:  }
  31:  
  32:  printf("Transpose \n");
  33:  
  34:  for (i=0; i<2; i++){
  35:      for(j=0;j<2;j++){
  36:  
  37:      printf(" %d",b[j][i]);
  38:  
  39:      }
  40:      printf("\n");
  41:  
  42:  }
  43:      getch();
  44:  }

Program ke tiga

   1:  #include <stdio.h>
   2:  #include <conio.h>
   3:  
   4:  
   5:  void main()
   6:  {
   7:  int j,i,a[2][2],x;
   8:  a[0][0]=1;
   9:  a[0][1]=2;
  10:  a[1][0]=5;
  11:  a[1][1]=6;
  12:  
  13:  
  14:  
  15:  for (i=0; i<2; i++){
  16:      for(j=0;j<2;j++){
  17:  
  18:      printf(" %d",a[i][j]);
  19:  
  20:      }
  21:      printf("\n");
  22:  }
  23:  
  24:  printf("Transpose \n");
  25:  
  26:  for (i=0; i<2; i++){
  27:      for(j=0;j<i;j++){
  28:  x=a[i][j];
  29:  a[j][i]=a[i][j];
  30:  a[i][j]=x;
  31:  
  32:      }
  33:  
  34:  
  35:  }
  36:  for (i=0; i<2; i++){
  37:      for(j=0;j<2;j++){
  38:  
  39:      printf(" %d",a[i][j]);
  40:  
  41:      }
  42:      printf("\n");
  43:  }
  44:  
  45:  
  46:      getch();
  47:  }

Sumber bacaan dan contoh:

  1. http://wiki.answers.com/Q/Write_a_c_program_to_find_transpose_of_a_matrix
  2. http://www.ittelkom.ac.id/admisi/elearning/prog3.php?proses=1&kd=Mat-010301&bab=Matriks&judul=Matematika&rincian=Pengertian%20Matriks&kd_judul=Mat-01&kode_bab=03&kode_sub=01

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s