SDUT 2057 金牌 银牌 铜牌

/SDUT 2057 金牌 银牌 铜牌
记录这个题之前先发表一下感受,这个题的整体思路不难,但实现起来不是很容易,至少对我来说。输出排名的函数一开始没写出代码来,受同学的启发,写出来,提交成功了,特意记录一下。
做完这个题之后,我发现在链表中排序可以作为一个模板,这个功能做题时用到不少。收藏这个模板,在以后
做题时会省很多时间。
以下是源码:
/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

struct Node
{
char Name[22];
int score;
struct Node *next;
};

void show (struct Node *x);//显示
struct Node *Creat(int n); //创建
struct Node *Add(struct Node *shead,struct Node *x);//增加
struct Node *Delete(struct Node * x,char str[]);//删除
struct Node *Change(struct Node *x,char str[],int score);//改变
void FindKing(struct Node *x);//找排名

struct Node *Sort(struct Node *x);//排序

int main ()
{
struct Node *head,*p;
int n,score;
char ch,str[22];
scanf ("%d",&n);
head=Creat(n);
while ((scanf (" %c",&ch))!=EOF)
{
if (ch==‘A’)
{
p=(struct Node *)malloc (sizeof (struct Node));
if (p= =NULL)
exit (0);
p->next=NULL;
scanf ("%s%d",p->Name ,&p->score );
head=Add(head,p);
}

  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值