#include<stdio.h>
#include<stdlib.h>
#define Max 11
typedef struct{
int data;
}A;
typedef struct{
A *elem;
int length;
}B;//数组建立顺序表
int main(){
B L;
L.elem=(A*)malloc(sizeof(A)*Max);
L.length=0;
printf("init_success!\n");
printf("input the length:");
scanf("%d",&L.length);
printf("input some data:\n");
for(int i=1;i<=L.length;i++){
scanf("%d",&L.elem[i].data);
}
printf("input what number you want to find:");
int temp,i;
scanf("%d",&temp);
L.elem[0].data=temp;
for(i=L.length;L.elem[i].data!=temp;i--){
}
if(i==0)printf("can't find\n");
else printf("%d\n",i);
printf("print the whole list:\n");
for(int j=0;j<=L.length;j++)printf(" %d",L.elem[j].data);
}
c语言数据结构---顺序查找表
最新推荐文章于 2024-11-03 22:17:06 发布