冒泡法
来源:互联网 发布:找出两列不同的数据 编辑:程序博客网 时间:2024/05/01 00:13
public class Test
{
public void Sx(int[] t)
{
for(int i = 0;i < t.length;i++)
{
if(t[i] < 10)
{
System.out.print("0"+t[i]+" ");
}
else
{
System.out.print(t[i]+" ");
}
if((i+1) % 6 == 0)
{
System.out.println();
}
}
}
public static void main(String[] args)
{
Test m = new Test();
int a[] = new int[36];
out1: for(int i = 0;i < 36;i++)
{
a[i] = (int)(Math.random() * 36 + 1);
for(int j = 0; j < 36 && j != i;j++)
{
if(a[j] == a[i])
{
i--;
continue out1;
}
}
}
m.Sx(a);
System.out.println();
//Arrays.sort(a);
//冒泡法
int temp;
for(int i=0;i<a.length;i++){
for(int j=0;j+1<a.length-i;j++){
if(a[j]>a[j+1]){
temp=a[j];
a[j]=a[j+1];
a[j+1]=temp;
}
}
}
m.Sx(a);
}
}
{
public void Sx(int[] t)
{
for(int i = 0;i < t.length;i++)
{
if(t[i] < 10)
{
System.out.print("0"+t[i]+" ");
}
else
{
System.out.print(t[i]+" ");
}
if((i+1) % 6 == 0)
{
System.out.println();
}
}
}
public static void main(String[] args)
{
Test m = new Test();
int a[] = new int[36];
out1: for(int i = 0;i < 36;i++)
{
a[i] = (int)(Math.random() * 36 + 1);
for(int j = 0; j < 36 && j != i;j++)
{
if(a[j] == a[i])
{
i--;
continue out1;
}
}
}
m.Sx(a);
System.out.println();
//Arrays.sort(a);
//冒泡法
int temp;
for(int i=0;i<a.length;i++){
for(int j=0;j+1<a.length-i;j++){
if(a[j]>a[j+1]){
temp=a[j];
a[j]=a[j+1];
a[j+1]=temp;
}
}
}
m.Sx(a);
}
}
0 0
- 冒泡法
- 冒泡法
- 冒泡法
- 冒泡法
- 冒泡法
- 冒泡法
- 冒泡法
- 冒泡法
- 冒泡法
- 【冒泡法】
- 冒泡法
- 冒泡法
- 冒泡法
- 冒泡法
- 冒泡法
- 冒泡法
- 冒泡法
- 冒泡法
- *LeetCode-Best Time to Buy and Sell Stock II
- Android开发规范
- 根据二叉树的中序和后序还原二叉树
- JavaScript多级菜单含有源码效果图示例
- iOS 完全复制UIView
- 冒泡法
- SSD 下的 MySQL IO 优化
- 带Mingw的code:blocks的安装指南
- 文章标题
- MySQL存储过程详解 mysql 存储过程mysql存储过程详解 1. 存储过程简介 我们常用的操作数据库语言SQL语句在执行的时候需要要先编译,然后执行,而存储过程(Stored
- Android的引用jar包
- Fragment
- 刚开始学的最基本的数据库实验
- Lecture3-1Learning with different output space