SoFunction
Updated on 2025-03-07

c# n number sorting implementation code


using System;

Namespace n numbers sort
{

class Class1
{

static void Main(string[] args)
{("Please enter the order in which you want to sort:\n");
int n;//Receive how many numbers you want to sort
n=(());
int[] A=new int[n];
("Please enter the number you want to sort in turn (the end of the number is represented by carriage input):\n");
for(int i=0;i<n;i++)//Receive the number you want to sort
A[i]=(());
for(int i=0;i<n;i++)//Sort
{
for(int j=i+1;j<n;j++)
{
int temp;
if(A[i]>A[j])
{
temp=A[j];
A[j]=A[i];
A[i]=temp;
}
}
}
("The result of sorting is:\n");
for(int i=0;i<n;i++)
(" "+A[i]);

(10000);
}
}
}