public class A {
public static void main(String[] args) {
int[] str={10,5,4,6,2,33,35};
int a,b;
for(int i=0;i<str.length;i++){
for (int j=i;j<str.length;j++){
if(str[i]>str[j])
{
int temp;
temp=str[i];
str[i]=str[j];
str[j]=temp;
}
}
}
for(int j=0;j<str.length;j++)
{
System.out.print(str[j]);
System.out.print(',');
}
}
}
public static void main(String[] args) {
int[] str={10,5,4,6,2,33,35};
int a,b;
for(int i=0;i<str.length;i++){
for (int j=i;j<str.length;j++){
if(str[i]>str[j])
{
int temp;
temp=str[i];
str[i]=str[j];
str[j]=temp;
}
}
}
for(int j=0;j<str.length;j++)
{
System.out.print(str[j]);
System.out.print(',');
}
}
}
解决方案 »
- 求救jsp中form提交问题~~~
- struts标签中文帮助文档(.chm)
- jsp 可编辑表格 我想要用JS实现 :点击表格 再点一个按钮 点击的那一行可以编辑(其他不行)
- struts2的标签怎么能放到一行里?
- 页面找不到servlet,请高手赐教
- 文件下载出了问题,搞了半天了!
- 在javaScript中怎么给全部的span标记设置颜色
- 高手们,求救了!!我想用ant实现两台服务器文件的备份,备份自动完成,且每天执行次数可以自己设定,请问怎么实现??
- 谁把jive的乱码问题解决了?指点一下 啊
- 一个字符串转换问题!! 急!!!15分钟以内,谢各位
- 求jsp高手做一个活 要求非常熟悉http协议 价钱面议
- 这样的网站值多少钱?
依次类推,第一个数(5)
{ //R(l..n)是待排序的文件,采用自下向上扫描,对R做冒泡排序
int i,j;
Boolean exchange; //交换标志
for(i=1;i<n;i++){ //最多做n-1趟排序
exchange=FALSE; //本趟排序开始前,交换标志应为假
for(j=n-1;j>=i;j--) //对当前无序区R[i..n]自下向上扫描
if(R[j+1].key<R[j].key){//交换记录
R[0]=R[j+1]; //R[0]不是哨兵,仅做暂存单元
R[j+1]=R[j];
R[j]=R[0];
exchange=TRUE; //发生了交换,故将交换标志置为真
}
if(!exchange) //本趟排序未发生交换,提前终止算法
return;
} //endfor(外循环)
} //BubbleSort