改错 查询时不对
#include<stdio.h> struct Staff{
char name[20];
double num;
};
int main()
{
int i,j, p=0;
double key;
struct Staff temp;
struct Staff staff[10]={{"郑 兵",201003020076},
{"宋 琪",20100302001},
{"宋 健",201003020077},
{"丹 丹",201003020054},
{"马 文",201003020090},
{"孙 林",201003020017},
{"王 昆",201003020012},
{"段 鹏",201003020040},
{"小 六",201003020080},
{"李 勇",201003020069}};
for(i=0;i<10;i++)
printf("%s %.0lf\n",staff[i].name,staff[i].num);
for(j=0;j<10;j++)
for(i=0;i<9-j;i++)
if(staff[i].num>staff[i+1].num){
temp=staff[i];
staff[i]=staff[i+1];
staff[i+1]=temp;
}
for(i=0;i<10;i++)
printf("从小到大输出:%s %.0lf\n",staff[i].name,staff[i].num);
while(p==0){
printf("input a staff's number:\n");//查询
scanf("%f",&key);
for(i=0;i<10;i++)
if(key==staff[i].num)
{
printf("%s %.0lf\n",staff[i].name,staff[i].num);
p=1;
}
else{
}
if(p==0)
printf("输入有误,重新出入!\n");
}
return 0;
}