当前位置:网站首页>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];
边栏推荐
- PTA:7-58 图书音像出租管理
- Leetcode 1208. 尽可能使字符串相等
- PTA:7-85 数据的间距问题(重载+函数模板)
- PTA:7-65 饮料的价格
- Code refactoring Guide
- After Huawei online battle service players quickly match, different players receive different lists of players in the same room
- Mobile terminal city list sorting JS plug-in vertitylist js
- P1347 sorting (TOPO)
- What is metadata
- PTA:7-67 友元很简单2016final
猜你喜欢
随机推荐
无线网络安全的12个优秀实践
PTA:7-63 计算高考状元
Sequence table lookup
PTA: spacing of 7-69 data
QMainWindow
Particle animation background login page particles js
Analysis on the current situation of the Internet of things in 2022
leetcode 91. Decode Ways 解码方法(中等)
Cool mouse following animation JS plug-ins 5
Please use the NLTK Downloader to obtain the resource
静态查找表和静态查找表
PTA:7-67 友元很简单2016final
2022金属非金属矿山(露天矿山)安全管理人员考试题模拟考试题库及答案
Ideal car × Oceanbase: when new forces of car building meet new forces of database
leetcode 91. Decode ways (medium)
Latest programming language rankings
【二叉树】翻转等价二叉树
Svg+js smart home monitoring grid layout
【深度学习】深度学习推理框架 TensorRT MNN OpenVINO ONNXRuntime
photoshop PS 查看像素坐标、像素颜色、像素HSB颜色






![[Shangshui Shuo series] day three - preview4](/img/c1/e840304a0a32c283c8720315a56716.png)


