Advertisement
Guest User

Untitled

a guest
Jan 16th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.50 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace _23.DiagonaalMatrix
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             const int ZIJDE = 5;
  14.             int[,] matrix = new int[ZIJDE, ZIJDE];
  15.             bool diagonaal = true;
  16.             for (int i = 0; i < ZIJDE; i++)
  17.             {
  18.                 for (int j = 0; j < ZIJDE; j++)
  19.                 {
  20.                     Console.Write("Geef getal in: ");
  21.                     matrix[i, j] = int.Parse(Console.ReadLine());
  22.                 }
  23.             }
  24.  
  25.             for (int i = 0; i < ZIJDE; i++)
  26.             {
  27.                 for (int j = 0; j < ZIJDE; j++)
  28.                 {
  29.                     Console.Write(matrix[i, j] + "\t");
  30.                 }
  31.                 Console.WriteLine();
  32.             }
  33.             for (int i = 0; i < ZIJDE; i++)
  34.             {
  35.                 for (int j = 0; j < i; j++)
  36.                 {
  37.                     if (i != j)
  38.                     {
  39.                         if (matrix[i, j] != 0)
  40.                         {
  41.                             diagonaal = false;
  42.                         }
  43.                     }
  44.                 }
  45.             }
  46.  
  47.             if (diagonaal)
  48.             {
  49.                 Console.WriteLine("Diagonaal Matrix");
  50.             }
  51.             else
  52.             {
  53.                 Console.WriteLine("Geen Diagonaal Matrix");
  54.             }
  55.         }
  56.     }
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement