Advertisement
Coulibaly343

MakeIdentity

Nov 20th, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.64 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 Cw1
  8. {
  9.     class Program
  10.     {
  11.  
  12.         static void Main(string[] args)
  13.         {
  14.                int[,] tab2D = new int[10, 10];
  15.                Make_Identity(tab2D);
  16.         }
  17.  
  18.   static void Make_Identity(int[,] tab2D)
  19.         {
  20.             int j = 0;
  21.             //Wypełnia 0
  22.             for (int i = 0; i < 10; i++)
  23.             {
  24.                 for (int c = 0; c < 10; c++)
  25.                 {
  26.                     tab2D[i, c] = 0;
  27.                 }
  28.             }
  29.             //Wypełnia 1 na głównej przekątnej
  30.             for (int i = 0; i < 10; i++)
  31.             {
  32.                 tab2D[i, j] = 1;
  33.                 j++;
  34.             }
  35.  
  36.             j = 0;
  37.  
  38.             foreach (int i in tab2D)
  39.             {
  40.                 Console.Write(i + " ");
  41.                 j++;
  42.                 if (j == 10)
  43.                     Console.WriteLine("");
  44.                 else if (j == 20)
  45.                     Console.WriteLine("");
  46.                 else if (j == 30)
  47.                     Console.WriteLine("");
  48.                 else if (j == 40)
  49.                     Console.WriteLine("");
  50.                 else if (j == 50)
  51.                     Console.WriteLine("");
  52.                 else if (j == 60)
  53.                     Console.WriteLine("");
  54.                 else if (j == 70)
  55.                     Console.WriteLine("");
  56.                 else if (j == 80)
  57.                     Console.WriteLine("");
  58.                 else if (j == 90)
  59.                     Console.WriteLine("");
  60.             }
  61.         }
  62.     }
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement