求问大神 用折返查找 加冒泡法 找元素 这边哪边错了
#define M 50#include<stdio.h>
#include<conio.h>
int search(int *st,int key ,int length)
{
int low =1 , high=length,mid,s;
while (low <= high)
{
mid=(high +low)/2;
if (key == st[mid])
return(mid);
else if (key < st[mid])
high = mid-1;
else low =mid +1;
}
return s;
}
void BubbleSort(int *st[],int length)
{
int n,i,j,x;
char change;
n = length; change=1;
for (i =1;i <=n-1&&change; i++)
{
change = 0;
for (j=1; j<=n-i;j++)
if (st[j]>st[j+1])
{
x=*st[j];
st[j]=st[j+1];
*st[j+1]=x;
change =1;
}
}
}
main()
{
int i,length;
int low,high,mid;
int key,s;
int st[M];
printf("Please input SSTable length:\n");
scanf("%d",&length);
printf("Please input SSTable data:\n");
for(i=1;i <= length; i++)
{
printf("%d:\t",i);
scanf("%d",&st[i]);
key=st[i];
}
printf("according to the order from small to large:\n");
void BubbleSort(int *st[],int length);
for(i=1;i <= length; i++)
{
ptintf("%d:\t",i);
ptintf("%d",st[i]);
printf("\n");
}
printf("Please input Search Key:\n");
scanf("%d",&key);
printf("\n");
s=search(*st,key,length);
if(s==0)
printf("%d is not here\n",key);
if(s!=0)
{
printf("%d is st[%d]\n",key,s);
}
getch();
}
下面是错误提示:
-------------------Configuration: 8 - Win32 Debug--------------------
Compiling...
8.c
D:\c语言\Debug\Debug\8.c(53) : error C2143: syntax error : missing ';' before 'type'
D:\c语言\Debug\Debug\8.c(56) : warning C4013: 'ptintf' undefined; assuming extern returning int
D:\c语言\Debug\Debug\8.c(65) : warning C4047: 'function' : 'int *' differs in levels of indirection from 'int '
D:\c语言\Debug\Debug\8.c(65) : warning C4024: 'search' : different types for formal and actual parameter 1
执行 cl.exe 时出错.
8.obj - 1 error(s), 0 warning(s)