帮我看一下这个程序错在哪多了?同时调用都调用不了……
#include<stdio.h>#include <conio.h>
#define N 5
void fun()
{
int i,j,t,a[N];
printf("please input array a:\n");
for(i=0;i<N;i++)
scanf("%d",&a[i]);
for(i=0;i<N-1;i++)
for(j=0;j<N-1-i;j++)
if(a[j]>a[j+1])
{t=a[j];a[j]=a[j+1];a[j+1]=t;}
printf("after score:");
for(i=0;i<5;i++)
printf("%d",a[i]);
}
void ch()
{
int left,right,mid,k,loca=-1;
int a[N];
printf("please input k:\n");
scanf("%d",&k);
left=0;right=N-1;mid=(left+right)/2;
while(left<=right)
{ if(k==a[mid])
{loca=mid;break;}
else if(k<a[mid])
{ right=mid-1;
mid=(left+right)/2;}
else
{left=mid+1;
mid=(left+right)/2;}
}
if (loca==-1)
printf("sorry can't found %d!\n",k);
else
printf("a[%d]=%d\n",loca,a[loca]);
}
void main()
{
int s;
scanf("%d",&s);
switch (s)
{case 1:fun();break;
case 2:ch();break;}
}