记录编号 |
579761 |
评测结果 |
AAAAAAAAAA |
题目名称 |
NBA总冠军 |
最终得分 |
100 |
用户昵称 |
abc |
是否通过 |
通过 |
代码语言 |
C++ |
运行时间 |
0.000 s |
提交时间 |
2023-07-13 16:05:33 |
内存使用 |
0.00 MiB |
显示代码纯文本
#include<iostream>
#include<string.h>
#include<algorithm>
#include<cstdio>
using namespace std;
struct team {
int year=0;
string name;
};
team winner[51];
bool cmp(team x,team y) {
if(x.year!=y.year)return x.year<y.year;
else return false;
}
int main() {
freopen("nba.in","r",stdin);
freopen("nba.out","w",stdout);
int n,j,str,i=1;
char zy[100],a;
cin>>n;
a=getchar();
//cout<<n;
for(i=1;i<=n;i++)
{
//cout<<i<<" ";
gets(zy);
//cout<<"yes";
str=strlen(zy);
j=0;
while((zy[j]>='A' && zy[j]<='Z') || (zy[j]>='a' && zy[j]<='z') || zy[j]==32)
{
if(j==str)break;
winner[i].name+=zy[j];
j++;
}
winner[i].year=(zy[str-1]-48)*1+(zy[str-2]-48)*10+(zy[str-3]-48)*100+(zy[str-4]-48)*1000;
}
for(i=1; i<=n; i++) {
sort(winner+1,winner+n+1,cmp);
}
for(i=1; i<=n; i++) {
if(winner[i].year!=winner[i-1].year)
{
cout<<winner[i].year;
cout<<" "<<winner[i].name<<endl;
}
}
}