当前位置:网站首页>Pta:6-33 student ranking table (destructor)
Pta:6-33 student ranking table (destructor)
2022-06-23 04:37:00 【Sy_ Faker】
Now enter a group of students ( There are more people than 0 And no more than 100) Their ranking and their names . It is required to output everyone's ranking by ranking .
Input format : The information of each student , Two items in total , The first item is the ranking ( As a positive integer , And the ranking of any two students is different ), The second item is the student's name . When the input -1 when , End of input .
Output format : Output student names by rank , Each row of a .
Function interface definition :
main Part of the function .
Sample referee test procedure :
#include <iostream>
#include <string>
using namespace std;
class Student{
int rank;
string name;
public:
int getRank(){
return rank; }
Student(string name, int rank):name(name), rank(rank){
}
~Student(){
cout<<name<<endl;}
};
int main(){
int rank, count=0;
const int SIZE=100;
Student *pS[SIZE];
string name;
cin>>rank;
while(count<SIZE && rank>0){
cin>>name;
pS[count++]= new Student(name, rank);
cin>>rank;
}
/* Please fill in the answer here */
return 0;
}
sample input :
1 Jack
5 Peter
2 Alice
6 Kate
52 Mike
-1
sample output :
Jack
Alice
Peter
Kate
Mike
I made it with bubble :
Student *temp;
for(int i=0;i<count;i++)
{
for(int j=i+1;j<count;j++)
{
if(pS[i]->getRank()>pS[j]->getRank())
{
temp=pS[i];
pS[i]=pS[j];
pS[j]=temp;
}
}
}
for(int i=0;i<count;i++)
delete pS[i];
边栏推荐
- Tables de recherche statiques et tables de recherche statiques
- Photoshop PS viewing pixel coordinates, pixel colors, pixel HSB colors
- Bug STM32 advanced timer (haha, to tell you the truth, the hardware timer can't reflect its strength. In fact, I want to send the kernel timer. Just think about it. Take your time)
- 【二叉樹進階】AVLTree - 平衡二叉搜索樹
- P1363 幻象迷宫(dfs)
- Particle animation background login page particles js
- 8 key indicators to measure technology debt in 2022
- 什么是元数据
- 制造型企业开发的SRM供应商管理系统特点是什么
- Imitation 360 desktop suspended ball plug-in
猜你喜欢

Ideal car × Oceanbase: when new forces of car building meet new forces of database

麦肯锡:2021年量子计算市场投资增长强劲,人才缺口扩大

LabVIEW在同一表中同时显示十六进制字符和普通字符

How to make the page number start from the specified page in word

【一起上水硕系列】Day Three - preview4

语料库数据处理个案实例(分词和分句、词频统计、排序)

Pytorch---使用Pytorch的预训练模型实现四种天气分类问题

【二叉樹進階】AVLTree - 平衡二叉搜索樹

Imitation 360 desktop suspended ball plug-in

x24Cxx系列EEPROM芯片C语言通用读写程序
随机推荐
基于FPGA的VGA协议实现
Inscription of lougu brush
[pycharm] ide Eval resetter
How to make the page number start from the specified page in word
Zhongang Mining: the demand for fluorite in the new energy and new material industry chain has increased greatly
x64dbg 基本使用技巧
Monitoring artifact ZABBIX, from deployment to application, goes deep layer by layer
Pta:7-85 data spacing (overload + function template)
X24cxx series EEPROM chip C language universal reading and writing program
[binary tree] completeness test of binary tree
国家药品不良反应监测中心 ADR 电子传输EDI解决方案
Implementation of VGA protocol based on FPGA
虫子 STM32 中断 (懂的都懂)
Halcon胶线检测—模板匹配、位姿变换、胶宽,胶连续性检测
[binary tree] flip equivalent binary tree
在线文本过滤小于指定长度工具
在线JSON转CSharp(C#)Class工具
leetcode 91. Decode Ways 解码方法(中等)
flutter系列之:flutter中的Wrap
What is the open source database under Linux