|
|
|
|
@ -170,10 +170,10 @@ void insertStudent(Student students[], int size, Student newStudent) {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
void printStudents(Student students[], int size) {
|
|
|
|
|
void printStudents(Student students[], int size,char insert[]) {
|
|
|
|
|
char m;
|
|
|
|
|
for (int i = 0; i < size; i++) {
|
|
|
|
|
if(strcmp(students[i].sid,"1004")==0)
|
|
|
|
|
if(strcmp(students[i].sid,insert)==0)
|
|
|
|
|
{
|
|
|
|
|
printf(" %s %d %.1f %.1f %.1f %.1f insert\n", students[i].sid, students[i].class, students[i].score[0], students[i].score[1], students[i].score[2], students[i].totalScore);
|
|
|
|
|
}
|
|
|
|
|
@ -190,6 +190,7 @@ int main() {
|
|
|
|
|
{"1003", 11, {92.5,99.0,60.5}, 252.0}
|
|
|
|
|
};
|
|
|
|
|
int size = 3;
|
|
|
|
|
char insert[10];
|
|
|
|
|
Student newStudent;
|
|
|
|
|
printf("请输入新学生信息:\n");
|
|
|
|
|
printf("学号:");
|
|
|
|
|
@ -198,11 +199,12 @@ int main() {
|
|
|
|
|
scanf("%d\n", &newStudent.class);
|
|
|
|
|
printf("三门课程成绩:");
|
|
|
|
|
scanf("%f\n %f\n %f\n", &newStudent.score[0], &newStudent.score[1], &newStudent.score[2]);
|
|
|
|
|
strcpy(insert,newStudent.sid);
|
|
|
|
|
newStudent.totalScore = newStudent.score[0] + newStudent.score[1] + newStudent.score[2];
|
|
|
|
|
insertStudent(students, size, newStudent);
|
|
|
|
|
size++;
|
|
|
|
|
printf("所有学生信息如下:\n");
|
|
|
|
|
printStudents(students, size);
|
|
|
|
|
printStudents(students, size,insert);
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
第5步骤
|
|
|
|
|
|