Page 34 - Struktur Data
P. 34

Menggunakan Nested Array





   Kelebihan                                                                               #define N 16



     Compiler C menangani array                                                           typedef int fix_matrix[N][N];

         secara double                                                                                      /* Compute element i,k of



     Menghasilkan kode sangat                                                                                    fixed matrix product */

         efisien                                                                                            int fix_prod_ele



             Menghindari perhitungan                                                                       (fix_matrix a, fix_matrix b,

               indeks ganda                                                                                 { int i, int k)



   Keterbatasan                                                                                                 int j;


     Hanya bekerja jika ukuran                                                                                 int result = 0;


         array tetap                                                                                            for (j = 0; j < N; j++)

                                                                                                                    result += a[i][j]*b[j][k];

                                                                                                                return result;

                                                                                                            }







                                                                                                                               COMPUTER REPAIR & SUPPORT
   29   30   31   32   33   34   35   36   37