A Simple IndexSearch
来源:互联网 发布:手机游戏映射软件 编辑:程序博客网 时间:2024/06/06 00:27
A simple index search,no illustrate,just simple.write it and practise,and feel it
// IndesSearch.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include "stdlib.h"
#define INDEXTABLE_LEN 3
#define TABLE_LEN 30
typedef struct item
{
int index;
int start;
int length;
}INDEXITEM;
long stu[TABLE_LEN]={
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
};
INDEXITEM indextable[INDEXTABLE_LEN]={
{10801,0,6},{10802,10,4},{10801,20,4}
};
int IndexSearch(int key)
{
int i,index1,start,length;
index1=key/100;
for(i=0;i<INDEXTABLE_LEN;i++)
{
if(indextable[i].index==index1)
{
start=indextable[i].start;
length=indextable[i].length;
break;
}
}
if(i>=INDEXTABLE_LEN) return -1;
for(i=start;i<start+length;i++)
{
if(stu[i]==key) return i;
}
return -1;
}
int InsertNode(int key)
{
int i,start,length;
int index1=key/100;
for(i=0;i<INDEXTABLE_LEN;i++)
{
if(indextable[i].index==index1)
{
start=indextable[i].start;
length=indextable[i].length;
break;
}
}
if(i>=INDEXTABLE_LEN) return -1;
stu[start+length]=key;
indextable[i].length++;
return 0;
}
int _tmain(int argc, _TCHAR* argv[])
{
int i=IndexSearch(1080201);
int j=InsertNode(1080204);
printf("%d,%d",i,j);
system("pause");
return 0;
}
- A Simple IndexSearch
- A simple bootstrap
- A Simple Java Program
- a simple ajax example
- A simple wxPython example
- a simple xml.
- A simple XDR program
- a rmi simple demo
- A Simple Input Form
- A simple perl class
- a simple jsm sample
- A simple Linux Socket
- A Simple XML Document
- A Simple Ordered Hashtable
- Create a simple module
- A Simple SMB Connection
- A simple DirectShow example
- A Simple PE Test
- 程序员们最好都读一下《大道至简》这本书
- opencv2.2.0源代码(include文件)分析(2)
- 达芬奇软件架构
- java克隆
- shell 脚本练习。笔记
- A Simple IndexSearch
- VC++学习心得! 学习c++的50条忠告 (初学者必看)
- 10 12 22 时间把握不好
- Linux进程间通信源码剖析,共享内存(shmget函数详解)
- 自定义Magento页标题与Meta描述
- Oracle 常用SQL --收藏
- autonomy
- 一些IT开发工程师的悲哀
- 详解二次封装VLAN技术——QINQ