[求助]程序输不出结果
public class test
{
public static void main(String[] args){
int a[]={12,34,11,3,23,41,12,1};
for(int i=0;i<7;i++)
{
for(int j=0;j<7-i;j++)
{
if(a[j]>a[j+1])
{
int t;
t=a[j];
a[j]=a[j+1];
a[j+1]=t;
}
}
}
for(int i=0;i<8;i++)
System.out.print(a[i]+" ");
System.out.println();
find b=new find();
System.out.println(b.finded(a,23,8));
}
}
class find
{
public int finded(int a[],int value,int size)
{
int i=0;
int start=0;
int end=size-1;
int mid=(start+end)/2;
while(start<=size-1)
{
if(a[mid]==value)
{
i=mid;
break;
}
if(a[mid]>value)
start=mid+1;
else
end=mid-1;
}
return i;
}
}
程序序不出我要找的元素