CodeBus
www.codebus.net
Search
Sign in
Sign up
Hot Search :
Source
embeded
web
remote control
p2p
game
More...
Location :
Home
Search - bubbleSort java
Main Category
SourceCode
Documents
Books
WEB Code
Develop Tools
Other resource
Sub Category
Button control
ComboBox
EditBox
TreeView
Static control
PropertySheet
RichEdit
ListView/ListBox
Menu control
ToolBar
StatusBar
Dialog_Window
Other
Tab Control
Search - bubbleSort java - List
[
GUI Develop
]
java
DL : 0
public class BubbleSort{ static String printArray(int[] a){ String result="" for(int i=0 i<a.length i++) result+=a[i]+" " return result } static int[] bubbleSort(int[] a){ int t for(int i=0 i<a.length i++) { for(int j=0 j<a.length-i-1 j++) //升序排列用大于,降序排列用小于,此处为降序排列。 if(a[j]<a[j+1]) {t=a[j] a[j]=a[j+1] a[j+1]=t } } return a } public static void main(String args[]) { int a[]={25,36,47,32,21,16} System.out.println("排序前的数组\n"+printArray(a)) a=bubbleSort(a) System.out.println("排序后的数组\n"+printArray(a)) } } -public class BubbleSort{ static String printArray(int[] a){ String result="" for(int i=0 i<a.length i++) result+=a[i]+" " return result } static int[] bubbleSort(int[] a){ int t for(int i=0 i<a.length i++) { for(int j=0 j<a.length-i-1 j++) //升序排列用大于,降序排列用小于,此处为降序排列。 if(a[j]<a[j+1]) {t=a[j] a[j]=a[j+1] a[j+1]=t } } return a } public static void main(String args[]) { int a[]={25,36,47,32,21,16} System.out.println("排序前的数组\n"+printArray(a)) a=bubbleSort(a) System.out.println("排序后的数组\n"+printArray(a)) } }
Date
: 2026-01-04
Size
: 3kb
User
:
jing
CodeBus
is one of the largest source code repositories on the Internet!
Contact us :
1999-2046
CodeBus
All Rights Reserved.