没有输入就直接跳过 咋回事
程序代码:
#include<stdio.h> #include<string.h> #define N 2 struct workman { char name[10]; float num; }work[N]; void getdate() { int i; printf("please input the name and number\n"); for(i=0;i<N;i++) scanf("%s%f",work[i].name,&work[i].num); } void arrange() { int i,j,n,t; char a[10]; for(i=0;i<N;i++) { t=i; for(j=i;j<N;j++) if(work[t].num>work[j].num) t=j; n=work[i].num; work[i].num=work[t].num; work[i].num=n; strcpy(a,work[i].name); strcpy(work[i].name,work[t].name); strcpy(work[t].name,a); work[i].name[strlen(work[i].name)]='\0'; work[i].name[strlen(work[t].name)]='\0'; } } int main() { int i; float t; arrange(); getdate(); printf("the arranged array is\n"); for(i=0;i<N;i++) printf("%-8s%.0f\n",work[i].name,work[i].num); printf("please input the workman's number\n"); scanf("%f",&t); for(i=0;i<N;i++) if(t==work[i].num) printf("%s\n",work[i].name); return 0; }输出有错误 且第二个scanf好像没执行