delete pics to save space
This commit is contained in:
38
history_source/ccf 基础篇/U3/3.5.1.cpp
Normal file
38
history_source/ccf 基础篇/U3/3.5.1.cpp
Normal file
@ -0,0 +1,38 @@
|
||||
#include<iostream>
|
||||
#include<string>
|
||||
using namespace std;
|
||||
struct people
|
||||
{
|
||||
string name;
|
||||
int f;
|
||||
};
|
||||
int n;
|
||||
int main()
|
||||
{
|
||||
people sr[100];
|
||||
int k;
|
||||
while(true)
|
||||
{
|
||||
cin>>n>>k;
|
||||
for(int i=0;i<n;i++) cin>>sr[i].name>>sr[i].f;
|
||||
bool b;
|
||||
people x;
|
||||
for(int i=n-1;i>0;i--)
|
||||
{
|
||||
b=1;
|
||||
for(int j=0;j<i;j++)
|
||||
{
|
||||
if(sr[j].f>sr[j+1].f){
|
||||
x=sr[j];
|
||||
sr[j]=sr[j+1];
|
||||
sr[j+1]=x;
|
||||
b=0;
|
||||
}
|
||||
}
|
||||
if(b) break;
|
||||
}
|
||||
cout<<endl;
|
||||
cout<<sr[k-1].name<<endl;
|
||||
cout<<endl;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user