HDU 2093 考试排名
2011-11-26 15:10
543 查看
http://acm.hdu.edu.cn/showproblem.php?pid=2093
View Code
View Code
#include <stdio.h> #include <string.h> #include <stdlib.h> struct student { char name[15]; int s,t; }a[1000]; char s1[15]; int n=0,m,tt; int cmp(const void *a,const void *b) { student *a1=(student*)a; student *b1=(student*)b; if (a1->s != b1->s) return b1->s - a1->s; if (a1->t != b1->t) return a1->t - b1->t; return strcmp(a1->name,b1->name); } int time(char *s) { int t1=0,i,j,t2=0; for (i=0;s[i]!='(' && s[i];i++) t1=t1*10+s[i]-'0'; if(s[i]) for (j=i+1;s[j]!=')';j++) t2=t2*10+s[j]-'0'; return t1+t2*tt; } int main() { scanf("%d%d",&m,&tt); while (scanf("%s",&a[++n].name)!=EOF) { a .s=a .t=0; for (int i=1;i<=m;i++) { scanf("%s",s1); if (s1[0]=='0' || s1[0]=='-') continue; a .s++; a .t+=time(s1); } } n--; qsort(a+1,n,sizeof(a[0]),cmp); for (int i=1;i<=n;i++) printf("%-10s %2d %4d\n",a[i].name,a[i].s,a[i].t); return 0; }
相关文章推荐
- hdu---2093考试排名
- 【HDU 2093】考试排名
- HDU 2093 考试排名
- HDU 2093 考试排名
- HDU 2093 考试排名
- hdu 2093 考试排名使用 sscanf () 用于判断输入有没有括号
- HDU 2093-考试排名(模拟题)
- HDU 2093 考试排名
- HDU 2093 考试排名 模拟题
- HDU 2093 考试排名
- HDU 2093 (考试排名)
- hdu 2093 考试排名
- HDU 杭电 acm-2093-考试排名
- HDU 2093 - 考试排名
- HDU——2093考试排名(string类及其函数的运用以及istringstream)
- hdu 2093 考试排名
- HDU 2093(考试排名)解题纠错
- HDU ACM 2093 考试排名
- HDOJ(HDU) 2093 考试排名(Arrays.sort排序、类的应用)
- hdu 2093 考试排名(结构体排序)