#include<stdio.h>
struct worklist
{int num;
char name[10];
}worker[10]={{2,"wang"},{1,"li"},{3,"zhang"},{7,"yang"},{8,"sun"},{5,"you"},{4,"miao"},{9,"wu"},{10,"han"},{6,"zhao"}};
char *find(int n)
{int low,mid,high,i,top,bot;
for(low=0,high=10;top<=bot;)
{mid=(top+bot)/2;
if(worker[n].num==worker[mid].num)
{return worker[mid].name;
break;
}
else if(worker[n].num>worker[mid].num) low=mid+1;
else high=mid-1;
}
}
void order()
{int i,j;
struct worklist temp;
for(i=0;i<10-1;i++)
for(j=0;j<10-i-1;j++)
if(worker[j].num>worker[j+1].num)
{temp=worker[j];worker[j]=worker[j+1];worker[j+1]=temp;}
}
void main(void)
{int i,num;
char *p;
char b[30];
clrscr();
for(i=0;i<10;i++)
printf("%d %4s\n",worker[i].num,worker[i].name);
sleep(2);
clrscr();
order();
for(i=0;i<10;i++)
printf("%d %4s\n",worker[i].num,worker[i].name);
sleep(1);
printf("Please Input a number:");
scanf("%d",&num);
p=find(num);
printf("%s",p);
getch();
return 0;
}