UVa 10194 - Football (aka Soccer)
来源:互联网 发布:内乡王登科网络诈骗 编辑:程序博客网 时间:2024/05/15 12:54
题目:给你一些球队的比赛记录,对球队的成绩进行排序。
分析:模拟。按照题意模拟即可。
排序优先级:1.分数高 ,2.胜场多,3.净胜球多,4.进球多,5.比赛场次少,6.队名字典序。
注意:队名大小写不敏感,即大小写认为是相同的。
#include <algorithm>#include <iostream>#include <cstdlib>#include <cstring>#include <cstdio>using namespace std;char title[104],name[104];typedef struct node{ char word[32]; int point,games,wins,losses,scored,against;}list;list dict[32];int small( char c ) {if ( c >= 'A' && c <= 'Z' )return c-'A'+'a';return c;}bool cmpstr( char* a,char* b ){int now = 0;while ( small(a[now]) == small(b[now]) )now ++;return small(a[now]) < small(b[now]);}bool cmp( list a, list b ){if ( a.point != b.point )return a.point > b.point;if ( a.wins != b.wins )return a.wins > b.wins;if ( a.scored-a.against != b.scored-b.against )return a.scored-a.against > b.scored-b.against;if ( a.scored != b.scored )return a.scored > b.scored;if ( a.games != b.games )return a.games < b.games;return cmpstr( a.word, b.word );}int find( char* word, int l, int n ) { for ( int i,j = 0 ; j < n ; ++ j ) { for ( i = 0 ; i < l ; ++ i ) if ( small(dict[j].word[i]) != small(word[i]) ) break; if ( i == l ) return j; }return -1;}void deal( int T ){int save = 0,s1,s2,t1,t2; while ( (name[save] = getchar()) != '#' ) save ++;t1 = find( name, save, T );scanf("%d",&s1);getchar();scanf("%d",&s2);getchar();save = 0; while ( (name[save] = getchar()) != '\n' ) save ++;t2 = find( name, save, T );dict[t1].games ++;dict[t1].scored += s1;dict[t1].against += s2;dict[t2].games ++;dict[t2].scored += s2;dict[t2].against += s1;if ( s1 > s2 ) {dict[t1].point += 3;dict[t1].wins ++;dict[t2].losses ++;}if ( s1 < s2 ) {dict[t2].point += 3;dict[t2].wins ++;dict[t1].losses ++;}if ( s1 == s2 ) {dict[t1].point ++;dict[t2].point ++;}}int main(){ int N,T,G; scanf("%d",&N); getchar();while ( N -- ) {memset( dict, 0, sizeof(dict) );gets(title); printf("%s\n",title); scanf("%d",&T);getchar(); for ( int i = 0 ; i < T ; ++ i ) gets(dict[i].word); scanf("%d",&G); getchar(); for ( int i = 0 ; i < G ; ++ i ) { deal( T );} sort( dict, dict+T, cmp );for ( int i = 0 ; i < T ; ++ i )printf("%d) %s %dp, %dg (%d-%d-%d), %dgd (%d-%d)\n",\i+1,dict[i].word,dict[i].point,dict[i].games,dict[i].wins,\dict[i].games-dict[i].wins-dict[i].losses,dict[i].losses,\dict[i].scored-dict[i].against,dict[i].scored,dict[i].against);if ( N ) printf("\n");} return 0;}
0 0
- uva 10194 Football (aka Soccer)
- UVa 10194 - Football (aka Soccer)
- uva 10194 - Football (aka Soccer)
- UVA 10194 - Football (aka Soccer)
- uva 10194Football (aka Soccer)
- UVa 10194 - Football (aka Soccer)
- UVA 10194 Football (aka Soccer)
- uva 10194 - Football (aka Soccer)
- uva -- 10194 - Football (aka Soccer)
- UVA 10194 - Football (aka Soccer)
- UVa 10194 - Football (aka Soccer)
- UVA 10194 Football (aka Soccer)
- UVa:10194 - Football (aka Soccer)
- UVa 10194 - Football (aka Soccer)
- UVA - 10194 Football (aka Soccer)
- uva 10194 Football (aka Soccer)
- UVA 10194 Football (aka Soccer)
- UVA Football (aka Soccer)
- 链栈的基本操作实现
- poj 2096<概率dp>
- 批处理删除svn信息:批处理
- java在命令提示符里运行
- 统计字符串A 在字符串B出现的个数
- UVa 10194 - Football (aka Soccer)
- ubuntu 安装maven提示出错 The program 'mvn' can be found in the following packages
- iOS开发常用国外网站清单
- LeetCode 40. First Missing Positive
- Java基本數據類型 長度和表示範圍
- 最新版的IOS真机测试教程
- Machine Learning Week 2 Linear Regression with multiple variables in Matlab or Octave
- 数组指针和指针数组的区别
- 链队的基本操作实现及约瑟夫环问题的队列解法