Advertisement
stoneman

zad6

Nov 15th, 2016
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.42 KB | None | 0 0
  1. using System;
  2.  
  3. namespace zad6
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int n;
  10.             int[,] mat;
  11.             int[,] t_mat;
  12.  
  13.             // Dimenzija matrice
  14.             Console.WriteLine("Dimenzija n matrice: ");
  15.             n = int.Parse(Console.ReadLine());
  16.  
  17.             mat = new int[n, n];
  18.             t_mat = new int[n, n];
  19.  
  20.             // Upis elemenata matrice
  21.             for(int i=0; i<n; i++)
  22.             {
  23.                 for(int j=0; j<n; j++)
  24.                 {
  25.                     Console.Write("Elemenat [" + i + ", " + j + "]: ");
  26.                     mat[i, j] = int.Parse(Console.ReadLine());
  27.                 }
  28.             }
  29.  
  30.             // Transponovanje
  31.             for (int i = 0; i < n; i++)
  32.             {
  33.                 for (int j = 0; j < n; j++)
  34.                 {
  35.                     if (i != j)
  36.                     {
  37.                         t_mat[i, j] = mat[j, i];
  38.                         t_mat[j, i] = mat[i, j];
  39.                     }
  40.                     else
  41.                         t_mat[i, j] = mat[i, j];
  42.                 }
  43.             }
  44.  
  45.             // Izlaz
  46.             for (int i = 0; i < n; i++)
  47.             {
  48.                 for (int j = 0; j < n; j++)
  49.                 {
  50.                     Console.Write(t_mat[i, j] + " ");
  51.                 }
  52.                 Console.WriteLine();
  53.             }
  54.         }
  55.     }
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement