#include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef struct student {
int id;
char name[20];
int score;
struct student *next;
} Student;
int main() {
int id, score;
char name[20];
Student *head, *p, *new_node;
head = p = NULL;
printf("倾输入请输入学生信息 (id 名字 分数): \n");
while (1) {
scanf("%d", &id);
if (id == 0)
break;
scanf("%s%d", name, &score);
new_node = (Student *) malloc(sizeof(Student));
new_node->id = id;
strcpy(new_node->name, name);
new_node->score = score;
new_node->next = NULL;
if (!head)
head = p = new_node;
else {
p->next = new_node;
p = new_node;
}
}
printf("请输入学生分数: ");
scanf("%d", &score);
printf("分数不低于的学生信息 %d:\n", score);
p = head;
while (p) {
if (p->score >= score)
printf("%d %s %d\n", p->id, p->name, p->score);
p = p->next;
}
return 0;
}
03-27
11-29
543
05-23
8104
04-19
5646
“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交