要实现一个C语言成绩查询系统,你可以按照以下步骤进行:
typedef struct {
int studentID;
char name[50];
float score;
} Student;
Student student;
printf("请输入学生信息:\n");
printf("学号:");
scanf("%d", &student.studentID);
printf("姓名:");
scanf("%s", student.name);
printf("成绩:");
scanf("%f", &student.score);
Student students[100];
int numStudents = 0;
students[numStudents++] = student;
int searchStudentByID(int studentID) {
for (int i = 0; i < numStudents; i++) {
if (students[i].studentID == studentID)
return i;
}
return -1;
}
int searchStudentByName(char *name) {
for (int i = 0; i < numStudents; i++) {
if (strcmp(students[i].name, name) == 0)
return i;
}
return -1;
}
int index = searchStudentByID(123456);
if (index != -1) {
printf("学号:%d\n", students[index].studentID);
printf("姓名:%s\n", students[index].name);
printf("成绩:%.2f\n", students[index].score);
} else {
printf("未找到该学生。\n");
}
以上是一个简单的C语言成绩查询系统的实现示例,你可以根据需要进行修改和扩展。