请帮忙看看这段程序的问题
#include "stdio.h"#include "conio.h"
#define N 10
void input(int num[N],char name[N][8])
{int i;
for(i=0;i<N;i++)
{printf("\nInput NO.:");
scanf("%d",&num[i]);
printf("Input name:"); 为什么运行时输入不了name
gets(name[i]);
}
}
void sort(int num[N],char name[N][8])
{int i,j,temp1;
char temp2[8];
for(i=0;i<N;i++)
for(j=0;j<N-i;j++)
if(num[j]>num[j+1])
{temp1=num[i];
num[i]=num[i+1];
num[i+1]=temp1;
strcpy(temp2,name[i]);
strcpy(name[i],name[i+1]);
strcpy(name[i+1],temp2);
}
printf("\nresult:\n");
for(i=0;i<N;i++)
printf("\n%5d%10s",num[i],name[i]);
}
void search(int n,int num[],char name[N][8])
{int top,bott,mid,loca,sign;
loca=0;
top=0;
bott=N-1;
sign=1;
if((n<num[0])||(n>num[N-1]))
loca=-1;
while((sign==1)&&(top<=bott))
{mid=(bott+top)/2;
if(n==num[mid])
{loca=mid;
printf("NO.%d,his name is%s.\n",n,name[loca]);
sign=-1;
}
else if(n<num[mid])
bott=mid-1;
else
top=mid+1;
}
if(sign==1||loca==-1)
printf("Can not find %d.\n",n);
}
main()
{int num[N],number,flag=1,c,n;
char name[N][8];
input(num,name);
sort(num,name);
while(flag==1)
{printf("\nInput number to look for:");
scanf("%d",&number);
search(number,num,name);
printf("Continue or not(Y/N)?");
getchar();
c=getchar();
if(c=='N'||c=='n')
flag=0;
}
getch();
}