Wednesday, 8 August 2018

contoh script java matrik dengan flowchart


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

namespace Auliya_rahmah
{
    class Program
    {
        static void Main(string[] args)
        {
            int x, y;
Console.Write("Masukan batas matrix : ");
x = int.Parse(Console.ReadLine());
y = x;
Console.WriteLine();
int[,] a = new int[x, y];
int[,] b = new int[x, y];
int[,] c = new int[x, y];
for (int i = 0; i < x; i++ ){
for (int j = 0; j < y; j++ ){
Console.Write("Inputkan data a [{0},{1}]: ",i,j);
a[i, j] = int.Parse(Console.ReadLine());
}
}
Console.WriteLine();
for (int i = 0; i < x; i++){
for (int j = 0; j < y; j++){
Console.Write("Inputkan data b [{0},{1}]: ", i, j);
b[i, j] = int.Parse(Console.ReadLine());
}
}
Console.WriteLine();
Console.WriteLine("Hasil Pengurangan :");
Console.WriteLine();
for (int i = 0; i < x; i++){
for (int j = 0; j < y; j++){
/* pengurangan matrix
int temp = 0;
for (int k = 0; k < x;k++ ){
temp = temp + a[i, k] - b[k, j];
}
c[i, j] = temp;*/
// pengurangan vektor
c[i, j] = a[i, j] - b[i, j];
Console.Write("{0} ",c[i,j]);
}
Console.WriteLine();
}
Console.ReadKey();
      }
    }
}


  Download script dan flowchart disini

No comments:

Post a Comment