_
gcu = tail -> head;
while (gcu != NULL) {
fwrite(gcu , sizeof(struct grade) , 1 , gfhead); gcu = gcu -> next; }
tail = tail -> next; }
fclose(afhead); fclose(gfhead); }
void addnew (struct address **head ) {
struct address *phead = NULL , *pTempNode = NULL; struct grade *gh = NULL;
pTempNode=(struct address *)malloc(sizeof(struct address));
printf(\);
_
scanf(\ , &pTempNode->stu_num);
printf(\); scanf(\ , pTempNode->hname);
printf(\); scanf(\ , pTempNode->ename);
printf(\); scanf(\ , pTempNode->depart);
printf(\);
scanf(\ , pTempNode->paddress);
printf(\); scanf(\ , pTempNode->phone); pTempNode -> next = NULL; pTempNode -> head = NULL; fflush(stdin);
printf(\);
pTempNode->head = (struct grade *)malloc(sizeof(struct grade));
_
scanf(\ , &pTempNode->head->score); gh = pTempNode->head;
printf(\);
gh -> next = (struct grade *)malloc(sizeof(struct grade)); gh = gh -> next;
scanf(\ , &gh -> score);
printf(\);
gh->next = (struct grade *)malloc(sizeof(struct grade)); gh = gh -> next;
scanf(\ ,&gh->score);
printf(\);
gh->next = (struct grade *)malloc(sizeof(struct grade)); gh = gh->next ;
scanf(\ , &gh->score);
printf(\);
gh->next = (struct grade *)malloc(sizeof(struct grade)); gh = gh->next ;
scanf(\ ,&gh->score);
_
printf(\);
gh->next = (struct grade *)malloc(sizeof(struct grade)); scanf(\ , &(gh->next->score)); gh->next->next = NULL ;
if((*head) == NULL) {
(*head) = pTempNode; } else {
phead = (*head);
while(phead != NULL && phead->next != NULL) {
phead = phead->next; }
phead->next = pTempNode; }
printf(\); }
_
二、设计思路
“任意增删”实现主要是靠链表。 “学生”是一种支持链表的结构体。 全局有一个“学生”的链表。
然后每个“学生”object下面又有各自的一个“科目”的链表。 (printf打印菜单文字内容,scanf获取输入等)。
C语言知识学习数据库-学生成绩统计管理组织系统



