Monday, 5 January 2015

Contoh Script Matrik dengan C#

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

namespace ConsoleApplication10
{
    class Program
    {
        static void Main(string[] args)
        {
            int[][] matriks = new int[3][];
            Console.WriteLine("masukkan nilai matriks");
            for (int i = 0; i < matriks.Length; i++)
            {
                matriks[i] = new int[3];
                for (int j = 0; j < matriks[i].Length; j++)
                {
                    Console.Write("matriks[{0}][{1}]= ", i, j);
                    matriks[i][j] = int.Parse(Console.ReadLine());
                }
            }
            Console.WriteLine();
            Console.WriteLine("menampilkan nilai matriks");
            for (int i = 0; i < matriks.Length; i++)
            {
                for (int j = 0; j < matriks[i].Length; j++)
                {
                    Console.Write("{0}", matriks[i][j]);
                }
                Console.WriteLine();
            }
            Console.Read();
        }

    }

Download script Link1 / Link2

No comments:

Post a Comment