博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
索引查找Java实现
阅读量:5069 次
发布时间:2019-06-12

本文共 1776 字,大约阅读时间需要 5 分钟。

package 索引查找;import java.util.Scanner;public class IndexSearch {	public static long stu[] = {		1080101,1080102,1080103,1080104,1080105,1080106,0,0,0,0,		1080201,1080202,1080203,1080204,0,0,0,0,0,0,		1080301,1080302,1080303,1080304,0,0,0,0,0,0	};		static Item[]indexTable = {			new Item(10801,0,6),			new Item(10802,10,4),			new Item(10803,20,4)	};		public static int indexSearch(int key){		int i,index1,start = 0,length = 0;		index1 = key/100;		for (i = 0;i
= indexTable.length) { return -1; } for (i = start;i
= indexTable.length) { return -1; } //保存关键字到主表中 stu[start+length] = key; indexTable[i].length++; return 0; } public static void main(String[] args) { Scanner input = new Scanner(System.in); System.out.println("原始数据:"); for (int i = 0;i
= 0) {// System.out.printf("查找成功,该关键字位于数组的第%d个位置\n",pos);// }else{// System.out.println("查找失败!");// } System.out.println("输入插入的关键字"); int num = input.nextInt(); if (insertNode(num) == -1) { System.out.println("插入失败!"); }else { for (int i = 0;i

 

package 索引查找; import java.util.Scanner; public class IndexSearch { public static long stu[] = { 1080101,1080102,1080103,1080104,1080105,1080106,0,0,0,0, 1080201,1080202,1080203,1080204,0,0,0,0,0,0, 1080301,1080302,1080303,1080304,0,0,0,0,0,0 }; static Item[]indexTable = { new Item(10801,0,6), new Item(10802,10,4), new Item(10803,20,4) }; public static int indexSearch(int key){ int i,index1,start = 0,length = 0; index1 = key/100; for (i = 0;i
= indexTable.length) { return -1; } for (i = start;i
= 0) { System.out.printf("查找成功,该关键字位于数组的第%d个位置\n",pos); }else{ System.out.println("查找失败!"); } } }

 

转载于:https://www.cnblogs.com/airycode/p/5197365.html

你可能感兴趣的文章
build.gradle 中compileSdkVersion,minSdkVersion,targetSdkVersion,buildToolsVersion的意思
查看>>
安装docker
查看>>
Jmeter VS LR参数取值方式和迭代方式
查看>>
Android 媒体键监听以及模拟媒体键盘的实现 demo
查看>>
面试题收集-腾讯
查看>>
【2019/5/18】周进度报告
查看>>
获取随机数
查看>>
block
查看>>
plsql 输出当月的所有日期
查看>>
[学习笔记]分块
查看>>
Visual Studio 2017 ASP.NET Core开发
查看>>
java多线程学习(两)——创建一个线程
查看>>
VirtualBox安装及使用说明和虚拟机安装XP系统图文教程
查看>>
DropdownList绑定的两种方法
查看>>
Oracle Enterprise Linux 64-bit下安装apache-tomcat-7.0.53步骤
查看>>
运行jar包
查看>>
转载--关于hdfs
查看>>
SharePoint 2013 图文开发系列之Visual Studio 创建母版页
查看>>
微软职位内部推荐-Software Engineer II
查看>>
小程序:彩票机选神器 !
查看>>