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)
- {
- int n = int.Parse(Console.ReadLine());
- MatrixMethod(n);
- }
- static void MatrixMethod(int x)
- {
- int temp = 0;
- bool swap = false;
- int[] arr = new int[x];
- for (int i = 0; i < x; i++)
- {
- arr[i] = int.Parse(Console.ReadLine());
- }
- for (int i = 0; i < x - 1; i++)
- {
- for (int j = 0; j < x - 1; j++)
- {
- if (arr[j] > arr[j + 1])
- {
- temp = arr[j];
- arr[j] = arr[j + 1];
- arr[j + 1] = temp;
- swap = true;
- }
- }
- if (swap == false)
- {
- break;
- }
- }
- for (int i = 0; i < x; i++)
- {
- Console.WriteLine(arr[i] + " ");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement