算法初步——哈希表B1047.编程团体赛

算法初步——哈希表B1047.编程团体赛_第1张图片

 

 

#include 
#include
#include <string>
using namespace std;
const int MAX_LEN = 10005;
//char str[MAX_LEN];
//int hashTable[30] = {0};
struct team{
    int teamnumber;
    int number;
    int grade;
}temp[MAX_LEN];
bool cmp(team a,team b){
    return a.grade > b.grade;
}
int main(){
    int n;
    cin>>n;
    for(int i=0;ii){
        temp[i].grade = 0;
    }
    int teamnumber1,number1,grade1;
    for(int i =0;ii){
        scanf("%d-%d%d",&teamnumber1,&number1,&grade1);
        temp[teamnumber1].teamnumber = teamnumber1;
        temp[teamnumber1].number = number1;
        temp[teamnumber1].grade += grade1;
    }
    sort(temp,temp+MAX_LEN,cmp);
    cout<0].teamnumber<<" "<0].grade;
    system("pause");
    return 0;
} 
 

你可能感兴趣的:(算法初步——哈希表B1047.编程团体赛)