当前位置:网站首页>C语言学生成绩排名系统
C语言学生成绩排名系统
2022-06-22 14:25:00 【Stephen_Curry___】
实验作业:用C语言设计函数输出对n个学生三门课程成绩总分排名。
一个小小的实验作业,感觉挺有意思的,这是我个人设计的代码,代码也不算复杂,主要就是涉及到链表的使用,很简单,代码如下:
#include<stdio.h>
#include<stdlib.h>
struct node
{
char name[50];
char eng[20];
int math1;
int math2;
int math3;
int sum=0;
int ran;
struct node *next;
}*head,*q,*t;
void my_sort(struct node *head)//学生成绩排序
{
struct node *cur, *tail,*tt;
cur=head;
tail=NULL;
if(cur==NULL||cur->next==NULL)return;
while(cur!=tail)
{
while(cur->next!=tail)
{
if(cur->sum>cur->next->sum)
{
cur->ran=cur->ran-1;
}
cur=cur->next;
}
if(cur->next==NULL)tt=cur;
tail=cur;
cur=head;
}
while(cur!=tt)
{
if(tt->sum>cur->sum)tt->ran--;
cur=cur->next;
}
}
void input(int n)//输入信息
{
struct node *p;
p=(struct node *)malloc(sizeof(struct node));
p->next= NULL;
scanf("%s%s%d%d%d",p->name,p->eng,&p->math1,&p->math2,&p->math3);
p->sum=p->math1+p->math2+p->math3;
p->ran=n;
if(head==NULL)head=p;
else q->next=p;
q=p;
}
void output()//输出信息
{
t=head;
while(t!=NULL)
{
printf("姓名:%s\n学号:%s\n总成绩:%d\n排名:%d\n",t->name,t->eng,t->sum,t->ran);
t=t->next;
}
}
int main()
{
head=NULL;
printf("请输入有几名同学:\n");
int n;
scanf("%d",&n);
printf("请分别输入姓名,学号,各科成绩:\n");
for(int i=0;i<n;i++)
{
input(n);
}
my_sort(head);
printf("学生成绩及排名如下:\n");
output();
}
边栏推荐
- Good wind relies on strength – code conversion practice of accelerating SQL Server Migration with babelfish
- Yilian technology rushes to Shenzhen Stock Exchange: annual revenue of RMB 1.4 billion, 65% of which comes from Ningde times
- 多年亿级流量下的高并发经验总结,都毫无保留地写在了这本书中
- Is SQL analysis query unavailable in the basic version?
- Countdown to the conference - Amazon cloud technology innovation conference invites you to build a new AI engine!
- Ultimate efficiency is the foundation for the cloud native database tdsql-c to settle down
- What does password security mean? What are the password security standard clauses in the ISO 2.0 policy?
- Simulation Keil et vspd
- Database connection pool: implementation of connection pool function point
- 迷宫问题(BFS记录路径)
猜你喜欢

MongoDB在腾讯零售优码中的应用

I rely on the sideline to buy a house in full one year: the industry you despise will make a lot of money in the next ten years!

多年亿级流量下的高并发经验总结,都毫无保留地写在了这本书中

历时100天、小鱼搭建了个机器人交流社区!!现公开邀请版主中!

Development status of full color LED display

The summary of high concurrency experience under the billion level traffic for many years is written in this book without reservation

百行代码实现基于Redis的可靠延迟队列

SDVO:LDSO+语义,直接法语义SLAM(RAL 2022)

2022年失业的人多吗?今年是不是特别难找工作?

模板特例化 template<>
随机推荐
SDVO:LDSO+语义,直接法语义SLAM(RAL 2022)
flutter video_ Player monitors and automatically plays the next song
建议自查!MySQL驱动Bug引发的事务不回滚问题,也许你正面临该风险!
The summary of high concurrency experience under the billion level traffic for many years is written in this book without reservation
NF RESNET: network signal analysis worth reading after removing BN normalization | ICLR 2021
New hybrid architecture iformer! Flexible migration of convolution and maximum pooling to transformer
Show me my personal work list for the past two years. I earn 6K a month in my spare time. It's so delicious to have a sideline
Is the encryption market a "natural disaster" or a "man-made disaster" in the cold winter?
DevSecOps: CI/CD 流水线安全的最佳实践
Database connection pool: stress testing
I rely on the sideline to buy a house in full one year: the industry you despise will make a lot of money in the next ten years!
数据库连接池:压力测试
U++ programming array learning notes
社区文章|MOSN 构建 Subset 优化思路分享
得物技术复杂 C 端项目的重构实践
Is SQL analysis query unavailable in the basic version?
Self inspection is recommended! The transaction caused by MySQL driver bug is not rolled back. Maybe you are facing this risk!
Ultimate efficiency is the foundation for the cloud native database tdsql-c to settle down
Tdengine connector goes online Google Data Studio store
FreeRtos 任务优先级和中断优先级