⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 2093.cpp

📁 杭电 acm部分代码 有兴趣的可以下载 谢谢
💻 CPP
字号:
#include <stdio.h>
#include <string>
#include <algorithm>
using namespace std;
struct acmer{
    int time;
    int solve;
    char name[12];
};
bool cmp(acmer r,acmer s){
    if(r.solve!=s.solve)
        return r.solve>s.solve;
    else{
        if(r.time!=s.time)
            return r.time<s.time;
        else
            return strcmp(r.name,s.name)<0;
    }
}
int main()
{
    int n,m,i,j,k,t,count=0,len;
    acmer stu[1000];
    scanf("%d%d",&n,&m);
    while(scanf("%s",stu[count].name)!=EOF){
        stu[count].solve=0;
        stu[count].time=0;
        for(i=0;i<n;i++){
            char str[10];
            scanf("%s",str);
            if(strcmp("0",str)==0)
                continue;
            if(str[0]=='-')
                continue;
            len=strlen(str);
            stu[count].solve++;
            k=0;
            if(str[len-1]==')'){
                j=len-2;
                k=str[j]-'0';
                j--;
                if(str[j]!='('){
                    k+=(str[j]-'0')*10;
                    j--;
                }
                j--;
            }
            else
                j=len-1;
            int x=1;
            t=0;
            for(;j>=0;j--){
                t+=(str[j]-'0')*x;
                x*=10;
            }
            stu[count].time+=(k*m+t);
        }
        count++;
    }
    sort(stu,stu+count,cmp);
    for(i=0;i<count;i++)
        printf("%-10s %2d %4d\n",stu[i].name,stu[i].solve,stu[i].time);
    return 0;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -