2021-5-4【PTA】【1004 成绩排名 (20 分)】

在这里插入图片描述

#include<bits/stdc++.h>
using namespace std;

struct stu{//结构体
	string name;
	string numb;
	int score;
}student[1000];

bool cmp(stu a,stu b){//排序方式
	return a.score>b.score;
}

int main(){
	int n;
	cin>>n;
	for(int i=0;i<n;i++){//结构体输入
		cin>>student[i].name>>student[i].numb>>student[i].score;
	}
	sort(student,student+n,cmp);//排序
	cout<<student[0].name<<" "<<student[0].numb<<endl;//输出
	cout<<student[n-1].name<<" "<<student[n-1].numb<<endl;
	return 0;
}
#include<iostream>
using namespace std;
int main()
{
 int n,m,max,min,t;
 char a[110][15],b[110][20];//注意所开数组的大小
 int c[10];
    cin>>n;
    for(int i=0;i<n;i++)
    {
     cin>>a[i]>>b[i]>>c[i];
 }
	m=c[0];
	t=c[0];
 for(int i=1;i<n;i++)
 {
 
  if(c[i]>m)
  {m=c[i];
  max=i;
 }
 if(c[i]<t)
  {t=c[i];
  min=i;
 }
 }
 cout<<a[max]<<" "<<b[max]<<endl;
 cout<<a[min]<<" "<<b[min]<<endl;
 
}
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Eternity_GQM

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值