#include <stdio.h>
#define MAX 100
typedef int datatype;
typedef struct{
datatype a[MAX];
int size;
}sequence_list; //定义一个数据结构,即相当一个数据类型
int emptyornot(sequence_list slt)
{
return(slt.size==0?0:1); //三目运算,判断是否有元素
}
void insert(sequence_list slt,datatype x,int i) //在数组a[i]插入数字
{
if(i>MAX||i<0) printf("you are a mader\n");
else slt.a[i]=x;
}
int find(sequence_list slt,datatype x) //在数组中查找元素x
{
int i=0;
for(;i<MAX;i++)
{
if(slt.a[i]==x)return i;
}
return 0;
}
本内容试读结束,登录后可阅读更多
下载后可阅读完整内容,剩余2页未读,立即下载