为什么我的程序运行不了
#define MAXSIZE 100
typedef int keytype;
typedef struct
{ keytype key;
}redtype;
typedef struct
{ redtype elem[MAXSIZE];
int length;
}Sstable;
int binsearch(Sstable ST,keytype Key)/二分法查找函数/
{ int low,mid,high;
low=1;high=ST.length;
while(low<=high)
{ mid=(low+high)/2;
if (Key==ST.elem[mid].key)
return mid;
else if (Key
else low=mid+1;
}
return 0;
}
main()/主函数/
{Sstable ST;
int i,pos,x,key;
pos=0;
printf("please input table length n:");/请求输入顺序表表长/
scanf("%d",ST.length);
printf("please input n data(sort):\n");/请求输入 n 个关键字值(必须升序排列)/
for(i=1;i<=ST.length;i++)
scanf("%d",ST.elem[i].key);
printf("please input key:");/请求输入待查找的记录关键字值/
scanf("%d",key);
binsearch(ST,key);/调用二分法查找函数/
if(pos==0)
printf("\nthe data is not found.\n"); /若找不到,提示信息/
else
printf("\nthe data is at position %d\n",pos);} /若找到,输出位置/
}
scanf("%d",&ST.length);
scanf("%d",&ST.elem[i].key);
scanf("%d",&key);
输入整数都是要取地址的
scanf("%d",&key);
所有的地方都要加上&