顺序表的实现(包含插入,删除,及查找)
来源:互联网 发布:紫砂壶淘宝店推荐 编辑:程序博客网 时间:2024/05/22 12:37
#include <stdio.h>
#define MAX 1000
int isfull(int n);//judge if the list is full or not
void insert(int *p,int len,int i,int elem);//*p represent the first element'id of list,i represent what location do you want to insert? elem represent what elementdo you want to insert?
void delete(int *pi,int len,int i);//*p represent the first element'id of list,i represent what location do you want to delete?
int lookelem(int *p,int n,int elem);//what element do you want to look for in the list?;n represent the length of the list.
main(){
int i,j,k;
int loca,elem;
int n
int s[MAX];
printf("please input list:")
for(i = 0;i < MAX;i++){
scanf("%d",s[i] != '\n');
}
printf("please choose: ");
printf("0 represent you want to insert element.\n");
printf("1 represent you want to delete element.\n");
printf("2 represent you want to look element.\n");
scanf("%d",&n);
switch(n){
printf("please choose:")
case 'o':
print("please input the location and element:");
scanf("%d,%d",&loca,&elem);
insert(s,i,loca,elem);
case'1':
print("please input the location and element:");
scanf("%d",&loca);
delete(s,i,loca);
case'2':
print("please input element:");
scanf("%d",&elem);
k = lookelem(s,i,);
if(j == 0 )
printf("the list have no element you want look\n");
else
printf("the list is %d",j);
default:
return -1;
}
printf("the last list is:\n");
for(k = 0;k < MAX;k++){
printf("%d",s[k]);
if(s[k] == '\0')
break;
}
}
int isfull(int n){
if(n > MAX)
printf(the list is full);
else
return 0;
}
void insert(int *p,int len,int i,int elem){
int j,k;
for(k = len;k > i;k--)
*(p+k) = *(p+k);
*(p+k) = elem;
isfull(len + 1);
printf("the list is:\n");
for(j = 0;j < len+2;j++)
printf("%d",*(p+j));
}
void delete(int *pi,int len,int i){
int j,k;
for(j = len;j < i;j--)
*(p+j) = *(p+j-1);
printf("now the list is:\n");
for(k = 0;k < len;k++)
printf("%d",*(p+k));
}
int lookelem(int *p,int n,int elem){
int k;
for(k = 0;k < n+1;k++){
if(elem = *(p+k))
return p;
else
return 0;
}
}
#define MAX 1000
int isfull(int n);//judge if the list is full or not
void insert(int *p,int len,int i,int elem);//*p represent the first element'id of list,i represent what location do you want to insert? elem represent what elementdo you want to insert?
void delete(int *pi,int len,int i);//*p represent the first element'id of list,i represent what location do you want to delete?
int lookelem(int *p,int n,int elem);//what element do you want to look for in the list?;n represent the length of the list.
main(){
int i,j,k;
int loca,elem;
int n
int s[MAX];
printf("please input list:")
for(i = 0;i < MAX;i++){
scanf("%d",s[i] != '\n');
}
printf("please choose: ");
printf("0 represent you want to insert element.\n");
printf("1 represent you want to delete element.\n");
printf("2 represent you want to look element.\n");
scanf("%d",&n);
switch(n){
printf("please choose:")
case 'o':
print("please input the location and element:");
scanf("%d,%d",&loca,&elem);
insert(s,i,loca,elem);
case'1':
print("please input the location and element:");
scanf("%d",&loca);
delete(s,i,loca);
case'2':
print("please input element:");
scanf("%d",&elem);
k = lookelem(s,i,);
if(j == 0 )
printf("the list have no element you want look\n");
else
printf("the list is %d",j);
default:
return -1;
}
printf("the last list is:\n");
for(k = 0;k < MAX;k++){
printf("%d",s[k]);
if(s[k] == '\0')
break;
}
}
int isfull(int n){
if(n > MAX)
printf(the list is full);
else
return 0;
}
void insert(int *p,int len,int i,int elem){
int j,k;
for(k = len;k > i;k--)
*(p+k) = *(p+k);
*(p+k) = elem;
isfull(len + 1);
printf("the list is:\n");
for(j = 0;j < len+2;j++)
printf("%d",*(p+j));
}
void delete(int *pi,int len,int i){
int j,k;
for(j = len;j < i;j--)
*(p+j) = *(p+j-1);
printf("now the list is:\n");
for(k = 0;k < len;k++)
printf("%d",*(p+k));
}
int lookelem(int *p,int n,int elem){
int k;
for(k = 0;k < n+1;k++){
if(elem = *(p+k))
return p;
else
return 0;
}
}
- 顺序表的实现(包含插入,删除,及查找)
- C语言顺序表的插入、删除、查找操作实现
- C语言实现顺序表的初始化,插入,删除,查找
- 动态顺序表的实现,插入删除查找修改...
- 线性表的输入输出插入删除查找(顺序表示)
- 顺序表插入 删除 查找
- c语言:顺序表的实现(一) 创建,插入,删除,查找,输出等基本操作实现
- 顺序表的实现以及简单的 插入,删除,查找,输出操作
- 【数据结构作业一】写出顺序表的结构体类型定义及查找、插入、删除算法,并以顺序表作存储结构,实现线性表的插入、删除
- C语言实现顺序表的插入、删除、查找、遍历等基本操作
- 顺序表的建立、插入、删除、查找、遍历操作
- 顺序表的查找、插入、删除、合并操作及其优缺点
- 线性表的顺序储存结构 初始化、查找、删除、插入
- 链表的实现(查找,插入,删除)
- 顺序表有关操作(查找、插入、删除)
- 顺序表(删除 、查找、插入、合并、输出)
- 顺序表 查找 插入 删除 操作
- 顺序表插入删除查找操作
- 聚类问题的次优解算法
- javascript 之 父子窗口 交互 动态增加option
- 创建地图
- 单词分界符
- url,urlconnection,httpurlconneciton实例
- 顺序表的实现(包含插入,删除,及查找)
- sybase中文乱码解决方案
- Openmesh halfedge find vertex
- 中断和异常
- DCMTK
- 黑马程序员_repeater控件研究入门
- linux学习
- USACO section 1.5.2 Prime Palindromes
- 程序员真的是吃青春饭的吗?(献给即将进入职场的程序员们)