学生考勤表的项目, 考勤表需要包括姓名,座号,手机3个数据成员。 成绩表需要包括姓名,语文成绩,英语成绩3个数据成员。 2. 用顺序表或者单链表实现
时间: 2023-06-01 21:03:45 浏览: 139
定义一个包含学生信息(学号,姓名,成绩)的顺序表
使用单链表实现学生考勤表和成绩表:
```python
class Student:
def __init__(self, name, seat_number, phone):
self.name = name
self.seat_number = seat_number
self.phone = phone
self.next = None
class AttendanceTable:
def __init__(self):
self.head = None
def add_student(self, name, seat_number, phone):
new_student = Student(name, seat_number, phone)
if self.head is None:
self.head = new_student
else:
current_student = self.head
while current_student.next is not None:
current_student = current_student.next
current_student.next = new_student
class Score:
def __init__(self, name, chinese_score, english_score):
self.name = name
self.chinese_score = chinese_score
self.english_score = english_score
self.next = None
class ScoreTable:
def __init__(self):
self.head = None
def add_score(self, name, chinese_score, english_score):
new_score = Score(name, chinese_score, english_score)
if self.head is None:
self.head = new_score
else:
current_score = self.head
while current_score.next is not None:
current_score = current_score.next
current_score.next = new_score
```
使用顺序表实现学生考勤表和成绩表:
```python
class Student:
def __init__(self, name, seat_number, phone):
self.name = name
self.seat_number = seat_number
self.phone = phone
class AttendanceTable:
def __init__(self):
self.students = []
def add_student(self, name, seat_number, phone):
new_student = Student(name, seat_number, phone)
self.students.append(new_student)
class Score:
def __init__(self, name, chinese_score, english_score):
self.name = name
self.chinese_score = chinese_score
self.english_score = english_score
class ScoreTable:
def __init__(self):
self.scores = []
def add_score(self, name, chinese_score, english_score):
new_score = Score(name, chinese_score, english_score)
self.scores.append(new_score)
```
阅读全文