链表A,每个节点存放一个新的链表B1,B2,B3,B4,B5的头结点。
场景:一个年级,相当链表A
该年级5个班,每个班5个人,相当于链表B1–B5
做一个学生成绩管理系统
学生成绩有语文 数学 英语
功能: 录入成绩 找最三科总分的最高分 最低分 算出平均分

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
struct people
{char* name;int lesson;int number;int math;int chinese;int english;int all;struct people* next;
};struct class
{int class;struct people* firstpeople;struct class* next;
};struct class* insertfromclassbehind(struct class* classhead,struct class* classnewnode)
{struct class* p=NULL;p=classhead;if(classhead==NULL){classhead=classnewnode;return classhead;}struct people* insertfrompeoplebefore(struct people* peoplehead,struct people* peoplenewnode)
{if(peoplehead==NULL){peoplehead=peoplenewnode;}else{peoplenewnode->next=peoplehead;peoplehead=peoplenewnode;}return peoplehead;
}void linkPrintf(struct class* head)
{struct people* p=NULL;if(head==NULL){printf("打印失败,链表为空\n");}while(head!=NULL){p=head->firstpeople;while(p!=NULL){printf("姓名:%s\n",p->name);printf("班级:%d\n",p->lesson);printf("学号:%d\n",p->number);printf("数学:%d\n",p->math);printf("语文:%d\n",p->chinese);printf("英语:%d\n",p->english);printf("---------------------------------------------------------------------------------------------------\n");p=p->next;}head=head->next;}
}struct class* creatnewlink(struct class* classhead,struct people* peoplehead,int classall)
{struct class* classnewnode=NULL;struct people* peoplenewnode=NULL;while(classall){int number;classnewnode=(struct class*)malloc(sizeof(struct class));classnewnode->next=NULL;classnewnode->firstpeople=NULL;printf("请输入班级:\n");scanf("%d",&classnewnode->class);printf("请输入该班的人数:\n");scanf("%d",&number);while(number){peoplenewnode=(struct people*)malloc(sizeof(struct people));peoplenewnode->next=NULL;peoplenewnode->name=(char*)malloc(128);memset(peoplenewnode->name,'\0',128);peoplenewnode->lesson=classnewnode->class;printf("请输入姓名:\n");scanf("%s",peoplenewnode->name);
//                      printf("输入的是:%s\n",peoplenewnode->name);printf("请输入学号:\n");scanf("%d",&peoplenewnode->number);printf("请输入数学成绩:\n");scanf("%d",&peoplenewnode->math);printf("请输入语文成绩:\n");scanf("%d",&peoplenewnode->chinese);printf("请输入英语成绩:\n");scanf("%d",&peoplenewnode->english);peoplenewnode->all=peoplenewnode->english+peoplenewnode->math+peoplenewnode->chinese;peoplehead=insertfrompeoplebefore(peoplehead,peoplenewnode);number--;}classnewnode->firstpeople=peoplehead;peoplehead=NULL;//printf("****************************");classhead=insertfromclassbehind(classhead,classnewnode);classall--;}return classhead;
}void findmaxall(struct class*head)
{struct class* p=head;struct people* p2=p->firstpeople;struct people* max=NULL;max=p2;if(p==NULL){printf("参数不能为空!\n");}while(p!=NULL){p2=p->firstpeople;while(p2!=NULL){if(max->all<=p2->all){max=p2;}p2=p2->next;}p=p->next;}printf("---------------------------------------------------------------------------------------------------\n");printf("总分最高为:%d,姓名:%s,班级:%d,学号:%d\n",max->all,max->name,max->lesson,max->number);printf("---------------------------------------------------------------------------------------------------\n");
}void findminall(struct class*head)
{struct class* p=head;struct people* p2=p->firstpeople;struct people* min=NULL;min=p2;if(p==NULL){printf("参数不能为空!\n");}while(p!=NULL){p2=p->firstpeople;while(p2!=NULL){if(min->all>=p2->all){min=p2;}p2=p2->next;}p=p->next;}printf("总分最低为:%d,姓名:%s,班级:%d,学号:%d\n",min->all,min->name,min->lesson,min->number);printf("---------------------------------------------------------------------------------------------------\n");
}void findaverage(struct class* head)
{int mathall,chineseall,englishall,peopleall;mathall=chineseall=englishall=peopleall=0;struct people* p;if(head==NULL){printf("链表为空错误\n");}while(head!=NULL){p=head->firstpeople;while(p!=NULL){mathall=p->math+mathall;chineseall=p->chinese+chineseall;englishall=p->english+englishall;peopleall++;p=p->next;}head=head->next;}//printf("语文:%d,数学:%d,英语:%d\n",chineseall,mathall,englishall);printf("语文平均分:%f\n",(float)chineseall/peopleall);printf("数学平均分:%f\n",(float)mathall/peopleall);printf("英语平均分:%f\n",(float)englishall/peopleall);printf("---------------------------------------------------------------------------------------------------\n");
}
int main()
{struct class* classhead=NULL;struct people* peoplehead=NULL;int classall;printf("请输入班级总数:\n");scanf("%d",&classall);classhead=creatnewlink(classhead,peoplehead,classall);findmaxall(classhead);findminall(classhead);findaverage(classhead);//linkPrintf(classhead);return  0;
}

一阶段结束考核题(链表的嵌套使用)相关推荐

  1. LeetCode分类刷题----链表篇

    链表 链表 1.移除链表元素 203.移除链表元素 707.设计链表 2.反转链表 206.反转链表 3.两两交换链表中的节点 24.两两交换链表中的节点 4.删除链表中的倒数第N个节点 19.删除链 ...

  2. 《缠中说禅108课》90:中阴阶段结束时间的辅助判断

    注意,这里给出的是中阴阶段结束时间的辅助判断,并不是一个绝对性的判断,如同用 MACD 判断背驰一样,只是一个辅助性,但由于准确率极高,绝对的判断反而因为太复杂而不实用,所以就可以一般性地利用这进行判 ...

  3. 计算机录入技能考试题,《计算机技能实训》考核题

    <计算机技能实训>考核题 06级本科 <计算机技能实训>考核题 一,填空题 1,计算机关机,除了依次单击[开始].[关闭计算机]外,也可以按[Alt]+[ F4   ]键. 2 ...

  4. 计算机信息化知识应用,计算机应用及信息化知识培训考核题库附答案.doc

    计算机应用及信息化知识培训考核题库附答案.doc 计算机应用及信息化知识培训考核题库附答案一.单项选择题(共173题)1.继WINDOWS2000系列之后,微软又推出了一代WINDOWS操作系统,它的 ...

  5. AutoLeaders算法组——二面考核题【萝卜埋地雷】

    AutoLeaders算法组--二面考核题[萝卜埋地雷]   描述  在家园保卫战中,萝卜们为了保卫自己的家园,在战线边界部署了地雷.在长长的战线边界中,其中一部分地块埋了地雷,另一部分却没有.  但 ...

  6. leetcode刷题链表

    leetcode刷题链表 反转链表Ⅱ 题目描述将一个节点数为 size 链表 m 位置到 n 位置之间的区间反转,要求时间复杂度 O(n)O(n),空间复杂度 O(1)O(1).例如: 给出的链表为9 ...

  7. iOS 第五期考核题(字典与数组嵌套,字典的排序/删除)

    1 /** 2 * 第1题 请将如下数据存储成字典,并将字典内容以字符串形式输出,输出:"XXX,年龄XXX岁,职业XXX"(将XXX替换为相应的数据). 3 */ 4 5 NSS ...

  8. Matrix工作室第六届纳新AI组考核题(B卷)

    一.单选题 下面哪个是Python中的不变的数据结构(C) A.set B.list C.tuple D.dict Python标准的内置数据类型有: Number(整数型 int , 浮点数型 fl ...

  9. LeetCode刷题——链表OJ(历时三天,万字博客,十一道经典题,带你手撕链表)

    知之愈明,则行之愈笃:行之愈笃,则知之益明. 学完链表,我们不得刷刷题增进对链表的认识?今天博主选取十一道经典链表题,从刷题者的角度剖析重点和易错点,讲解最简单的方法,文章内附题目和题目链接,重点内容 ...

最新文章

  1. 【Git报错】 ! [rejected] master - master (fetch first)
  2. 版权之争,谁更棋高一着?
  3. [密码学] 复杂性理论基础
  4. C++ Boost在Windows和Linux下的编译安装
  5. 用科幻艺术描绘未知的魅力-环境篇
  6. TensorFlow使用CNN实现中文文本分类
  7. python如何计算字符宽度_Python中计算字符宽度
  8. Java可能使用UTF-8作为其默认字符集
  9. 201506230818_《JavaScript权威指南(第六版)——callee和caller、对象属性用作实参、自定义函数属性》(P175-180)...
  10. 装机之windows10和ubuntu双系统
  11. kali装电脑_教你Kali Linux怎么安装Nessus软件
  12. Django model update的各种用法介绍
  13. Mysql like ' ' 会不会用到索引
  14. c# asp.net页面传值方法总结
  15. 后缀数组算法概述及习题
  16. Learning Affinity from Attention End-to-End Weakly-Supervised Semantic Segmentation withTransformers
  17. Vc++ - qt - 仿照微信聊天窗口 - demov.1.0 初步展示
  18. 绘制花朵Flower
  19. ShareSDK QQ平台注册
  20. Jmeter对webSocket测试

热门文章

  1. TCP/IP 通信示例
  2. python 定时自动爬取_python实现scrapy爬虫每天定时抓取数据的示例代码
  3. 凭证 金蝶_金蝶软件账务处理流程之——凭证录入
  4. java的日期操作_java中对时间的操作详解
  5. [10] AOP的注解配置
  6. 2017软件工程实践总结
  7. 超轻量级DI容器框架Google Guice与Spring框架的区别教程详解及其demo代码片段分享...
  8. debian jessie install note
  9. Vim中数字自增、自减
  10. BW:BW增量更新方法(假增量)