冒泡排序`交换排序·二分查找
来源:互联网 发布:个股龙虎榜数据 编辑:程序博客网 时间:2024/05/23 16:56
public static void main(String[] args) {
int[] a = new int[] {1,2,3};
int [] b = new int[4];
System.arraycopy(a,0,b,0,4);
for(int i = 0;i<b.lentth;i++) {
System.out.println(b[i]);
}
}
}
三维数组。type[][][] a = new type[2][3][4];
public class ArrayTest {
poublic static void main(String[] args) {
int [][][] a =new int[2][3][4];
System.out.println(a instanceof int[][][]);
System.out.println(a instanceof object);
System.out.println(a[0] instanceof int[][]);
System.out.println(a[0][0] instanceof int[]);
for(int i = 0; i<a.length; i++) {
for (int j = 0;j <a[i].length;j++){
for(int k = 0;k <a[i][j].length;k++){
a[i][j][k] = 100;
}
}
}
}
}
冒泡排序: (掌握交换排序,快速排序的原理与实现方式)
public class BubbleSortTest {
public static void bubbleSort(int[] array){
for(int i = 0;i < array.length - 1; i++) {
for(int j = 0;j < array.length - i - 1;j++) {
if(array[j] > array[j+1]) {
int temp = array[j];
array[j] = array[j+1];
array[j+1]= temp;
}
}
System.out.println("第" + (i + 1) + "次排序");
for(int k = 0; k < array.length; k++) {
System.out.print(array[k] + " ");
}
System.out.println();
}
}
public static void main(String[] args) {
int[] array = {4,9,2,8,6,1};
bubbleSort(array);
}
}
public class ArrayTest {
public static void main(String[] args) {
int[] a = new int[] {1,2,3};
int [] b = new int[4];
System.arraycopy(a,0,b,0,4);
for(int i = 0;i<b.lentth;i++) {
System.out.println(b[i]);
}
}
}
三维数组。type[][][] a = new type[2][3][4];
public class ArrayTest {
poublic static void main(String[] args) {
int [][][] a =new int[2][3][4];
System.out.println(a instanceof int[][][]);
System.out.println(a instanceof object);
System.out.println(a[0] instanceof int[][]);
System.out.println(a[0][0] instanceof int[]);
for(int i = 0; i<a.length; i++) {
for (int j = 0;j <a[i].length;j++){
for(int k = 0;k <a[i][j].length;k++){
a[i][j][k] = 100;
}
}
}
}
}
冒泡排序: (掌握交换排序,快速排序的原理与实现方式)
public class BubbleSortTest {
public static void bubbleSort(int[] array){
for(int i = 0;i < array.length - 1; i++) {
for(int j = 0;j < array.length - i - 1;j++) {
if(array[j] > array[j+1]) {
int temp = array[j];
array[j] = array[j+1];
array[j+1]= temp;
}
}
System.out.println("第" + (i + 1) + "次排序");
for(int k = 0; k < array.length; k++) {
System.out.print(array[k] + " ");
}
System.out.println();
}
}
public static void main(String[] args) {
int[] array = {4,9,2,8,6,1};
bubbleSort(array);
}
}
int[] a = new int[10];
int[] a = {new int[]}{1,2,3,4,5,6}
数组的属性 length是public final int的,一旦确定不能改变。
二维数组是一种平面的二维结构
int[][] a = new int[2][3];
第一个方括号里代表行,第二个代表列
三维数组
int[][][] a = new type[2][3][4];
二分查找(Binary Search):待查找的数组要有序
import java.util.Random;
public class RandomTest {
public static void main(String[] args) {
Random random = new Random();
for(int i = 0;i < 50;i++){
//System.out.println(random.nextInt(41)+10);
//}
double result = Math.random();
result *= 41;
int result2 = (int)result;
result2+= 10;
System.out.println(result2);
}
}
import java.util.Random;
public class RandomTest {
public static void main(String[] args) {
int[] count = new int[41];
Random random = new Random();
for(int i = 0; i<50;i++){
int number = random.nextInt(41)+ 10;
count [number -10]++;
}
for(int i = 0; i<count.length; i++) {
}
}
}
- 冒泡排序`交换排序·二分查找
- 冒泡排序+二分查找
- 冒泡排序、二分查找
- #笔记#圣思园 JavaSE 第35讲——冒泡排序、交换排序、快速排序、二分查找
- 冒泡排序和二分查找
- 二分查找与冒泡排序
- 冒泡排序和二分查找
- 冒泡排序和二分查找
- 冒泡排序及二分查找
- 二分查找以及冒泡排序
- java 冒泡排序二分查找
- 冒泡排序,插入排序,二分查找
- 冒泡排序、选择排序、二分查找法
- 选择排序 冒泡排序 二分查找
- 冒泡排序,快速排序,二分查找
- Java 冒泡排序,选择排序,二分查找
- JAVA冒泡排序,归并排序,二分查找
- php 冒泡排序 快速排序 二分查找
- iOS开发之:AssetsLibrary框架访问相册所有照片实现多选照片
- 多台服务器间无密码访问
- SQL Server 2005 创建链接服务器
- iOS8自定义cell的删除按钮、更多、置顶等按钮的样式
- 黑马程序员-c语言基础自增自减问题
- 冒泡排序`交换排序·二分查找
- POJ 1141
- KM算法模板
- [150518]spring四种依赖注入方式
- 我的第一篇博客,仅做一些预言
- Ural 2018 The Debut Album
- git 的一些用法
- iOS开发 FFmpeg 编译及使用
- OLAP与OLTP