Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace Homework3
- {
- using System;
- class Task_3
- {
- static void Main(string[] args)
- {
- int[] arr = { 1, 2, 25, -3, 75, 4, 5, 6, 10, -9, 5, 0, 15, 25, -50, -99, 0, -1025, 54, -6, -458, 56, -3, 6 };
- int[] result = SortArrayOfDescendingOrder(arr);
- PrintArray(result);
- }
- static int[] SortArrayOfDescendingOrder(int[] arr)
- {
- int[] result = new int[arr.Length];
- for (int i = 0; i < arr.Length; i++)
- {
- result[i] = arr[i];
- }
- for (int i = 0; i < result.Length; i++)
- {
- for (int j = 1; j < result.Length - i; j++)
- {
- if (result[j - 1] < result[j])
- {
- int swap = result[j - 1];
- result[j - 1] = result[j];
- result[j] = swap;
- }
- }
- }
- return result;
- }
- {
- string s = "";
- for (int i = 0; i < arr.Length; i++)
- {
- s += $"{arr[i]} ";
- }
- Console.WriteLine(s);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement