順序表: 就所謂的陣列式操作
程式設計實現順序儲存結構中的基本操作的實現(**本的建立、插入、刪除、修改、逆置、查詢、輸出)
整個操作過於簡陋, 只對上述功能做敘述, 採用結構體陣列實現, 本打算用class操作, 可因為某種原因就擱置了………..
**中的注釋部分是用於測試資料, **本只存有number, name
在寫**的過程中出現的問題是://size全域性變數表示**本當前大小不包含0位置,0號位置作為中間變數處理, 重新申請中間變數太麻煩了就省略
//#include
#include
#define maxsize 100
#define null 0
int size=0; //表示當前**本中有幾個聯絡人的資訊
typedef
structtelephone;
telephone t[maxsize];//建立結構體陣列的時候,可採用new,此處對此操作省略
void create();
int find(int lo,int hi,telephone t,char* target_value);
void insert(telephone t,int size);
void display(telephone t,int size);
void convert(telephone t,int size);
void create()
int find(int lo,int hi,telephone t,char target_value)
//在插入的過程中使用插入排序,以便於find操作
void insert(telephone t,int t_size)
//此處的j指向剛插入的元素的位置
strcpy(t[j+1].name,t[0].name);//哨兵放置
strcpy(t[j+1].number,t[0].number);
++size; //每插入乙個人的資訊,size增加一次
// printf("當前i=%d insert後size=%d\n",i,size);
}// printf("insert後size=%d\n",size);
return;
}int remove(telephone t,char* target_value,int t_size)
// strcpy(t[i].name,"\0");
// strcpy(t[i].number,"\0");//將要刪除的元素的name.number置為空串
// if(location==size)
size--;
return location;
// printf("remove後size=%d\n",size);
}void display(telephone t,int size)
void convert(telephone t,int size)
}int main()else
printf("未建立**本,不可刪除,查詢,展示,倒置操作");
case
7: key=0;break; }}
return
0;}
雜湊表的應用之電話本
include include include include using namespace std struct phone 初始化為空 class myphone bool find string a,int ranks for int i 0 i s int pos s.find 0 判斷有...
基於java的電話本管理系統
本程式本人寫了三個類分別為phonebook telephoneitem ui telephoneitem package com.hpe.test public class telephoneitem 帶引數的構造方法 public telephoneitem string name,string...
C語言 用鍊錶實現電話本的功能
簡介 用鍊錶實現 本的功能 c語言 本具有如下4個功能 1.建立乙個 本,本裡面包含名字和 號碼 2.在指定位置插入乙個名字和 號碼 3.在指定位置刪除乙個名字和 號碼 4.列印 本 其中那個color函式是我為了美觀加上去的,如果感覺不需要的話可以將 中所有有關color的都刪掉即可 includ...