Advertisement
stoneman

zad6

Nov 15th, 2016
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.23 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.  
  12.             // Dimenzija matrice
  13.             Console.WriteLine("Dimenzija n matrice: ");
  14.             n = int.Parse(Console.ReadLine());
  15.  
  16.             mat = new int[n, n];
  17.  
  18.             // Upis elemenata matrice
  19.             for(int i=0; i<n; i++)
  20.             {
  21.                 for(int j=0; j<n; j++)
  22.                 {
  23.                     Console.Write("Elemenat [" + i + ", " + j + "]: ");
  24.                     mat[i, j] = int.Parse(Console.ReadLine());
  25.                 }
  26.             }
  27.  
  28.             // Transponovanje
  29.             for (int i = 0; i < n; i++)
  30.             {
  31.                 for (int j = 0; j < n; j++)
  32.                 {
  33.                     int temp = mat[i, j];
  34.                     mat[i, j] = mat[j, i];
  35.                     mat[j, i] = temp;
  36.                 }
  37.             }
  38.  
  39.             // Izlaz
  40.             for (int i = 0; i < n; i++)
  41.             {
  42.                 for (int j = 0; j < n; j++)
  43.                 {
  44.                     Console.Write(mat[i, j] + " ");
  45.                 }
  46.                 Console.WriteLine();
  47.             }
  48.         }
  49.     }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement