1176:谁考了第k名
作者:互联网
传送门:http://ybt.ssoier.cn:8088/problem_show.php?pid=1176
#include<iostream> #include<cstring> #define N 110 using namespace std; struct q{ string as; float b; }a[N]; int main(){ int n,k; cin>>n>>k; for(int i=1;i<=n;i++)cin>>a[i].as>>a[i].b; for(int i=1;i<=n-1;i++) { int tmp=i; for(int j=i+1;j<=n;j++) if(a[j].b>a[tmp].b)tmp=j; swap(a[i],a[tmp]); } cout<<a[k].as<<" "<<a[k].b<<endl; }
标签:tmp,1176,cn,show,int,include 来源: https://www.cnblogs.com/jzxnl/p/11070231.html