3
21/10/2024 6:26 pm
Topic starter
Hi, please help me with this task:
Write a program that reads a number n and a sequence of n integers, sorts them and prints them.
Examples:
1 Answer
2
21/10/2024 6:28 pm
Here is my solution with arrays and the Sort method of the Array Class:
using System; class SortingNumbers { static void Main() { int n = int.Parse(Console.ReadLine()); int[] arrayNumbers = new int[n]; for (int i = 0; i < n; i++) { arrayNumbers[i] = int.Parse(Console.ReadLine()); } Array.Sort(arrayNumbers); foreach (var VARIABLE in arrayNumbers) { Console.WriteLine(VARIABLE); } } }