提交方式:C++(不需要加return和})

#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
int tot[100000];
int num[100000];
int ids[100000];
char names[200][10000];
int nameLens[200];

int main()
{
    FILE* fp;
    int i, j, n;
    if ((fp = fopen("score.dic", "r")) == NULL)
    {
        printf("can not open.\n");
        exit(0);
    }
    int id,score;
    char name[100];
    int cnt=0;
    int tmpID=-1;
    while(~fscanf(fp,"%d%s%d",&id,&name,&score)){
        if(id!=tmpID){
            cnt++;
            tmpID=id;
        }
        num[cnt]++;
        tot[cnt]+=score;
        ids[cnt]=id;
        int nameLen=strlen(name);
        nameLens[cnt]=nameLen;
        for(int i=0;i<nameLen;i++){
            names[cnt][i]=name[i];
        }
    }
    for(int i=1;i<=cnt;i++){
        cout<<ids[i];
        double aver=tot[i]/num[i];
        cout<<" "<<aver<<endl;
    }