问题遇到的现象和发生背景
学生链表的构造与输出
问题相关代码,请勿粘贴截图
运行结果及报错内容
我的解答思路和尝试过的方法
我想要达到的结果
#include <iostream>
#include <iomanip>
using namespace std;
struct Student{
long number;
float score;
Student* next;
};
; // 定义头节点
Student* getNode(){
int num;
float sc;
cin >> num >> sc;
if(num == 0) {
return NULL;
}
Student* p = new Student;
p->number = num;
p->score = sc;
p->next = 0;
return p;
}
void Create() {
if((head = getNode()) == 0) { // 添加结束条件
break;
;
}
for ( ) { // 循环添加
pE->next = pS;
}
}
void ShowList() {
cout << "now the itens of list are \n";
for( ) { // 循环输出
cout<< p->number << "," << p->score << endl;
}
}
int main(){
cout << fixed << setprecision(1);
Create();
ShowList();
}