Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace zad6
- {
- class Program
- {
- static void Main(string[] args)
- {
- int n;
- int[,] mat;
- int[,] t_mat;
- // Dimenzija matrice
- Console.WriteLine("Dimenzija n matrice: ");
- n = int.Parse(Console.ReadLine());
- mat = new int[n, n];
- t_mat = new int[n, n];
- // Upis elemenata matrice
- for(int i=0; i<n; i++)
- {
- for(int j=0; j<n; j++)
- {
- Console.Write("Elemenat [" + i + ", " + j + "]: ");
- mat[i, j] = int.Parse(Console.ReadLine());
- }
- }
- // Transponovanje
- for (int i = 0; i < n; i++)
- {
- for (int j = 0; j < n; j++)
- {
- if (i != j)
- {
- t_mat[i, j] = mat[j, i];
- t_mat[j, i] = mat[i, j];
- }
- else
- t_mat[i, j] = mat[i, j];
- }
- }
- // Izlaz
- for (int i = 0; i < n; i++)
- {
- for (int j = 0; j < n; j++)
- {
- Console.Write(t_mat[i, j] + " ");
- }
- Console.WriteLine();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement