如果问题得到解决,请点下采纳
// Q1077615.cpp : Defines the entry point for the console application.
//
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <string>
using namespace std;
struct student
{
unsigned long id;
string name;
float score;
student *next; //下一个结点的指针
};
int main()
{
student head = {-1,"",0};
head.next = NULL;
student * p = &head;
FILE * fp = fopen("Score.txt", "r+");
while (true)
{
unsigned long id;
char name[100];
float score;
if (fscanf(fp, "%ld,%[^,],%f", &id, name, &score) == EOF) break;
p->next = new student;
p = p->next;
p->next = NULL;
p->id = id;
p->name = name;
p->score = score;
}
int n;
while (1)
{
cin >> n;
if (n == 0) break;
p = head.next;
while (p)
{
if (p->id == n)
{
cout << p->name << " " << p->score << endl;
break;
}
p = p->next;
}
if (!p || p->id != n)
cout << "no record!" << endl;
}
return 0;
}
210871,张三,95
210872,lisi,92.5
210873,jim zhao,97
210874,han meimei,100
210875,孙行者,80
210876,tony,80
210877,铁柱,94.5
210878,小明,98

完整代码下载
https://download.csdn.net/download/caozhy/12453617