To arrange the numbers of an int array from small to large (C #)

Source: Internet
Author: User
Array

Using System;

Namespace ConsoleApplication1
{
<summary>
Summary description of the CLASS1.
</summary>
Class Class1
{
<summary>
The main entry point for the application.
</summary>
[STAThread]
static void Main (string[] args)
{
Mintomax mtm= new Mintomax ();
int [] array = {1,2,6,3,8,3,4,0,5,23,52,12,234,235,1232,21,234,123,143,1368};
Int[] Last=mtm. MTM (array);
int n=0;
for (int i=0;i<array. length;i++)
{
System.Console.Write (last[i]+ "<");
++n;

}
System.Console.WriteLine ("\ n Total {0} digits", n);

System.Console.ReadLine ();
//
TODO: Add code here to start the application
//
}
}

public class Mintomax
{
Public int[] MTM (int [] array)

{
Int[] fianlmtm= new Int[array. Length];

for (int j=0;j<array. length;j++)
{
int last=0;
for (int i=1;i<array. length-j;i++)
{
int t = array[i];

if ((Array[i]) < (Array[i-1])
{

ARRAY[I]=ARRAY[I-1];
Last=array[i];
array[i-1]=t;

}
Else
Last=array[i];

}
Fianlmtm[array. length-(j+1)]=last;

}
return FIANLMTM;

}
}
}




Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.