hdu acm steps 1.3.5
来源:互联网 发布:农村淘宝服务站 昆山 编辑:程序博客网 时间:2024/04/29 22:39
题目:http://acm.hdu.edu.cn/game/entry/problem/show.php?chapterid=1§ionid=3&problemid=12
结构体排序处理。
下面是AC代码:
#include <cstdio>#include <cstdlib>#include <cstring>#define MAX 1000typedef struct{ char name[11]; int sum; int total;}credit;int cmp(const void *a, const void *b){ if ((*(credit *)a).total != (*(credit *)b).total) return (*(credit *)a).total - (*(credit *)b).total; else if ((*(credit *)b).sum != (*(credit *)a).sum) return (*(credit *)b).sum - (*(credit *)a).sum; else return strcmp((*(credit *)b).name, (*(credit *)a).name);}int main(){ int res, t, f; int i, n, m, j; char style[10]; credit c[MAX] = {0}; scanf ( "%d%d", &n, &m ); for ( i = 0; scanf("%s", c[i].name) != EOF; i++ ) { for ( j = 0; j < n; j++ ) { scanf ( "%s", style ); res = sscanf(style, "%d(%d)", &t, &f ); if ( res == 2 ) { c[i].total++; c[i].sum += t + f * m; } else if (res == 1 && t > 0) { c[i].total++; c[i].sum += t; } } } qsort(c, i, sizeof(credit), cmp); for ( i--; i >= 0; i-- ) { printf("%-10s %2d %4d\n", c[i].name, c[i].total, c[i].sum); } return 0;}
- hdu acm steps 1.3.5
- hdu ACM Steps 1.3
- hdu ACM Steps 1.3.5 排序
- hdu acm steps 1.3.1
- hdu acm steps 1.3.2
- hdu acm steps 1.3.3
- hdu acm steps 1.3.4
- hdu acm steps 1.3.6
- hdu acm steps 1.3.7
- hdu acm steps 1.3.8
- hdu acm steps 2.1.5
- hdu acm steps 2.2.5
- hdu ACM steps 1.3.4 hdu 2561
- hdu ACM steps 1.2.5 hdu3188
- hdu ACM Steps 1.1
- hdu ACM Steps 1.2
- hdu ACM Steps 2.1
- hdu ACM Steps 2.2
- 步骤一:申请域名
- Current Issues and Trends in Meshing and Geometric Processing for Computational Engineering Analyses
- linux设备驱动结构梳理
- 一个不错的书籍分享网站
- 步骤二:买空间或者用自己电脑做服务器
- hdu acm steps 1.3.5
- Wireshark检测不到网卡解决方案
- Android 软件管理器的开发1
- Delphi 使用HLP文件制作系统的帮助文档
- hdu acm steps 1.3.6
- 步骤三:域名解析,收尾
- 哈希结构---访问大文件(查看单个文件中出现最多的单词)
- IAR安装与破解WIN7版本
- struts原理与实践(二)