PCA Matriks

Algoritma FPB dan Pengaplikasiaan kedalam bahasa pemrograman C#

Matrik

Dalam update content blog ini, saya akan mengisi mengenai topik matrik, penggunaan matriks disini masih dengan matrik biasa dengan proses dasar contoh matriks 2D :

Demo Program

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Matriks_dasar
{
    class Program
    {
        static void Main(string[] args)
        {
            int a, b, c, d, e, f, g, h, total1 = 0,total2 = 0,total3 = 0,total4 = 0;
            int tot1 = 0, tot2 = 0, tot3 = 0, tot4 = 0, to1 = 0, to2 = 0, to3 = 0, to4 = 0;

            Console.WriteLine("Matrik A :");
            Console.Write("0.0 = ");
            a = Convert.ToInt32(Console.ReadLine());
            Console.Write("0.1 = ");
            b = Convert.ToInt32(Console.ReadLine());
            Console.Write("1.0 = ");
            c = Convert.ToInt32(Console.ReadLine());
            Console.Write("1.1 = ");
            d = Convert.ToInt32(Console.ReadLine());

            Console.WriteLine("\nMatrik B :");
            Console.Write("0.0 = ");
            e = Convert.ToInt32(Console.ReadLine());
            Console.Write("0.1 = ");
            f = Convert.ToInt32(Console.ReadLine());
            Console.Write("1.0 = ");
            g = Convert.ToInt32(Console.ReadLine());
            Console.Write("1.1 = ");
            h = Convert.ToInt32(Console.ReadLine());
            
            //Penjumlahan Matriks
            total1 = a + b; total2 = b + f; total3 = c + g; total4 = d + h;
            //Pengurangan Matriks
            tot1 = a - b; tot2 = b - f; tot3 = c - g; tot4 = d - h;
            //Perkalian Matriks
            to1 = (a * e) + (b * g);
            to2 = (a * f) + (b * h);
            to3 = (c * e) + (d * g);
            to4 = (c * f) + (d * h);

            Console.WriteLine("\nHasil Penjumlahan Matriks : ");
            Console.WriteLine("|{0}{1}|\n|{2}{3}|", total1, total2, total3, total4);

            Console.WriteLine("Hasil Pengurangan Matriks : ");
            Console.WriteLine("|{0}{1}|\n|{2}{3}|", tot1, tot2, tot3, tot4);

            Console.WriteLine("Hasil Penjumlahan Matriks : ");
            Console.WriteLine("|{0}{1}|\n|{2}{3}|", to1, to2, to3, to4);
            Console.ReadKey();
        }
    }
}

Untuk Matriks Dinamisnya (Comming Soon)

Tidak ada komentar:

Posting Komentar