C:\Program Files\Microsoft Visual Studio\MyProjects\jifao\a.c(23) : error C2143: syntax error : missing ';' before 'type'
C:\Program Files\Microsoft Visual Studio\MyProjects\jifao\a.c(24) : error C2143: syntax error : missing ';' before 'type'
C:\Program Files\Microsoft Visual Studio\MyProjects\jifao\a.c(25) : error C2065: 'mid' : undeclared identifier
C:\Program Files\Microsoft Visual Studio\MyProjects\jifao\a.c(25) : error C2065: 'low' : undeclared identifier
C:\Program Files\Microsoft Visual Studio\MyProjects\jifao\a.c(25) : error C2065: 'high' : undeclared identifier
C:\Program Files\Microsoft Visual Studio\MyProjects\jifao\a.c(26) : error C2065: 'x' : undeclared identifier
以上为错误类型,以下为程序,看不懂了。。。。。。冒泡排序法部分无错,烦请费心。
#include<stdio.h>
main()
{
int num[15]={0,1,2,3,4,5,6,7,8,9,10,11,12,13,14};
int i,j,t;
for(i=0;i<15;i++)
{
for(j=0;j<14-i;j++)
{
if(num[j]>num[j+1])
{
t=num[j];
num[j]=num[j+1];
num[j+1]=t;
}
}
}
for(i=0;i<15;i++)
{
printf("%d ",num[i]);
}
printf("\n");
int low=0,high=14;
int mid,x;
mid=(low+high)/2;
scanf("%d",&x);
while(low<=high)
{
if(x>num[mid])
{
low=mid+1;
}
else if(x<num[mid])
{
high=mid-1;
}
else
{
printf("x是数组中第%d个元素\n",mid);
x=1;
break;
}
}
if(x!=1)
printf("无此数\n");
}
AAnonymous
AAnonymous
相关分类