数组的排序问题案例
来源:互联网 发布:网络消费积分的信用卡 编辑:程序博客网 时间:2024/06/05 12:07
package TestArray;/** * Created by Administrator on 2017/5/3. */public class HighArray { int[] a = new int[5]; int n = 0 ; public void insert(int value){ a[n] = value; n++; if ( n == a.length-1){ int[]b=new int[a.length*2]; for (int i = 0; i <n ; i++) { b[i]=a[i]; } a=b; } } public boolean find(int key){ // 77 99 int i; for (i = 0; i <n ; i++) { if(a[i] == key ){ //找到了 break; } } if( i < n ){ return true; }else{ return false; } } /** * 找到这个key所在的下标 * @param index * @return */ public int findindex(int index){ int j; for ( j = 0; j <n ; j++) { if (index==a[j]){ return j; } } return -1; } public void display() { for (int i = 0; i < n; i++) { System.out.print(a[i] +" "); } } public void delete(int value){ int delIndex = findindex(value); for (int i = delIndex; i <n ; i++) { a[i]=a[i+1]; } n--; }}
package TestArray;/** * Created by Administrator on 2017/5/3. */public class HighArrayApp { public static void main(String[] args) { HighArray arraylist = new HighArray(); arraylist.insert(77); arraylist.insert(99); arraylist.insert(33); arraylist.insert(55); System.out.print("您输入的数组为:"); arraylist.display(); System.out.println(); System.out.println("下标为:"+arraylist.findindex(99)); arraylist.delete(77); System.out.print("删除77以后的数组:"); arraylist.display(); System.out.println(); for (int i = 0; i <88 ; i++) { arraylist.insert(i); } arraylist.display(); }}
0 0
- 数组的排序问题案例
- 数组排序的问题
- 数组的排序问题。
- 数组的排序问题
- 这是数组升序的排序的案例
- php 数组的排序问题
- php 数组的排序问题
- C++的数组排序问题。
- 特殊的数组排序问题
- 特殊的数组排序问题
- JS数组排序的问题
- 特殊的数组排序问题
- 关于数组排序的问题
- 关于排序问题-冒泡排序的简单案例
- 数组试题---特殊的数组排序问题
- 关于数组的.sort()方法案例:删除数组中重复的元素并排序
- C++字符数组越界问题的一个案例分析
- C++字符数组越界问题的一个案例分…
- rabbitmq的简单使用(2)
- MySql实现tab自动补全
- ToolBar、DrawerLayout和设置导航按钮
- IOS UIScrollView 手势返回冲突处理
- 软件设计之软件系统不是木桶型的
- 数组的排序问题案例
- elasticsearch 安装过程中可遇到的问题
- 【译】Nodejs最好的ORM
- UISliderEx 封装方法
- 雅虎十四条:网站前端网页优化的14条原则
- 1098. Insertion or Heap Sort (25)
- 预处理,结构体
- iOS 极光推送开发环境可以收到,生产环境收不到推送
- phpexcel中文教程-设置表格字体颜色背景样式、数据格式、对齐方式、添加图片、批注、文字块、合并拆分单元格、单元格密码保护