Cx330_按姓名的字典顺序排出成绩表

Cx330_按学号查找学生成绩并显示查找结果
Cx330 2 years ago
parent 6ba25868b1
commit 3362254958

@ -249,9 +249,7 @@ void SortbyName(STU stu[],int n,int m)
``` ```
void SearchbyNum(STU stu[],int n,int m) void SearchbyNum(STU stu[],int n,int m)
{ {
long number;
int i,j;
printf("Input the number you want to search:");
} }
``` ```
@ -259,7 +257,24 @@ void SearchbyNum(STU stu[],int n,int m)
``` ```
void SearchbyName(STU stu[],int n,int m) void SearchbyName(STU stu[],int n,int m)
{ {
char x[MAX_LEN];
int i,j;
printf("Input the name you want to search:");
scanf("%s", x);
for(i=0;i<n;i++)
{
if(strcmp(stu[i].name,x)==0)
{
printf("%ld\t%s\t",stu[i].num,stu[i].name);
for(j=0;j<m;j++)
{
printf("%.0f\t",stu[i].score[j]);
}
printf(".0f\t%.0f\n",stu[i].sum,stu[i].aver);
return;
}
}
printf("\nNot found!\n);
} }
``` ```

Loading…
Cancel
Save