Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace Matrix
- {
- class Program
- {
- static void Main(string[] args)
- {
- MatrixMethod();
- }
- static void MatrixMethod()
- {
- int[,] arr = { { 21, 19, 113, 55 }, { 33, 15, 60, 7 } };
- Console.WriteLine("Before ");
- for (int i = 0; i < arr.GetLength(0); i++)
- {
- for (int j = 0; j < arr.GetLength(1); j++)
- {
- Console.Write("{0,4}", arr[i, j]);
- }
- Console.WriteLine();
- }
- Console.WriteLine("After");
- for (int i = 0; i < arr.GetLength(0); i++)
- {
- for (int j = arr.GetLength(1) - 1; j > 0; j--)
- {
- for (int k = 0; k < j; k++)
- {
- if (arr[i, k] > arr[i, k + 1])
- {
- int temp = arr[i, k];
- arr[i, k] = arr[i, k + 1];
- arr[i, k + 1] = temp;
- }
- }
- }
- }
- for (int i = 0; i < arr.GetLength(0); i++)
- {
- for (int j = 0; j < arr.GetLength(1); j++)
- {
- Console.Write("{0,4}", arr[i, j]);
- }
- Console.WriteLine();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement