Tutorials to .com

Tutorials to .com » Dotnet » Csharp » C # bubble algorithm!

C # bubble algorithm!

Print View , by: iSee ,Total views: 0 ,Word Count: 276 ,Date: Wed, 22 Jul 2009 Time: 3:51 AM

Written on many occasions to participate in, there are as many as several times the bubble test method, one is c # version of the fill in the blank, one is to write all the javascript version.
Although every time with my understanding of the lawbubble out, but a little more or less difference between the standard model, the Internet has been found about the C++ # version of the bubble algorithm, nor even a decent, their mode control algorithm to write a serious C # version has been tested successfully.

【Accompanied Bubble Sort Animation】

public void BubbleSort (int [] R)
(
int i, j, temp;
/ / Exchange logo
bool exchange;
/ / Up to do to sort R.Length-1 times
for (i = 0; i <R. Length; i + +)
(
/ / Sort the times before the start of the exchange of signs should be false
exchange = false;
for (j = R.Length-2; j> = i; j -)
(
/ / Exchange
if (R [j +1] <R [j])
(
temp = R [j +1];
R [j +1] = R [j];
R [j] = temp;
/ / Occurrence of the exchange, it will be home for the real exchange logo
exchange = true;
)
)
/ / Sort this trip was no exchange, early termination algorithm
if (! exchange)
(
break;
)
)
)



c # (csharp) Articles


Can't Find What You're Looking For?


Rating: Not yet rated

Comments

No comments posted.