就是比如有2,3,6,9,0,1,5,8,7,4 十个偶数位数字,从中间分开,前五位从小到大排,后五位从大到小排。要用JAVA语言的冒泡排序法,谁会?写一下。谢
解决方案 »
- struts2 <s:select> 标签多选
- 怎么把收到的javax.net.ssl.SSLSocket对象,发送给另一台服务器?
- spring配置问题
- blazeds could not initialize proxy
- spring+ibatis整合的一个奇怪问题,问题解决给分
- jsp怎么得到二进制,求代码
- 有谁遇到过 javax.servlet.jsp.el.ELException: 异常?
- maven Unable to locate NamespaceHandler for namespace [http://www.springframewor
- SaxException:File "c:\xml\reports.xml"not found
- 在写servlet时连接数据库出现No operations allowed after connection closed
- java程序员学习linux应该掌握到什么地步呢???
- s:action 不起作用是怎么回事
int [] arr = {2,6,3,9,0,1,5,8,7,4 };//定义一个数组用来存储5个5-15之间的随机数
int count = arr.length/2;
int [] a = new int[count];//存储arr[]数组的前几个元素
int [] b = new int[count];//存储arr[]数组的后几个元素
//先将数组[] arr 分成两个数组
for (int i = 0; i < count; i++) {
a[i] = arr[i];
}
int o,j,temp;
for(o=0;o<a.length-1;o++ ){
for(j=0;j<a.length-o-1;j++){
if(a[j]>a[j+1] ) //较大的元素后移
{
temp=a[j];
a[j]=a[j+1];
a[j+1]=temp;
}
}
}
for (int i = 0; i < a.length; i++) {
System.out.print(a[i]+"===");
}
for (int i = 5; i < arr.length; i++) {
b[i-count] = arr[i];
}
for(o=0;o<b.length-1;o++ ){
for(j=0;j<b.length-o-1;j++){
if(b[j]<b[j+1] ) //较大的元素后移
{
temp=b[j];
b[j]=b[j+1];
b[j+1]=temp;
}
}
}
for (int i = 0; i < b.length; i++) {
System.out.print(b[i]+"===");
}