Football (aka Soccer) -uva10194 模拟题
来源:互联网 发布:如何查个人大数据征信 编辑:程序博客网 时间:2024/06/03 18:40
简单的模拟,不过超级麻烦、、、注意字典序排序的时候是对大小写不敏感的,一开始因为这个点被卡了好几次。。。。
#include<cstdio>#include<cstring>#include<iostream>#include<algorithm>#define MAX_SIZE 1000 + 100#define MAXD 1000 + 20using namespace std;struct Team{ char name[MAX_SIZE];/*球队名字*/ int score;/*积分*/ int win; /*胜利场数*/ int lose;/*失败场数*/ int tie; /*平均场次*/ int player;/*总共比赛场次*/ int Get;/*得球*/ int Lost;/*失球*/ int Get_Lost;/*得球-失球*/};void str_str(char x[]){ /*转化大小写*/ for(int i=0;i<strlen(x);i++){ if(x[i]>='a'&&x[i]<='z') x[i]-=32; }}bool cmp(Team x,Team y){ if(x.score<y.score) return false; if(x.score>y.score) return true; if(x.win<y.win) return false; if(x.win>y.win) return true; if(x.Get_Lost<y.Get_Lost) return false; if(x.Get_Lost>y.Get_Lost) return true; if(x.Get<y.Get) return false; if(x.Get>y.Get) return true; if(x.player<y.player) return true; if(x.player>y.player) return false; str_str(x.name); str_str(y.name); if(strcmp(x.name,y.name)>0) return false; else return true;}int main(){ int N; scanf("%d",&N); getchar(); for(int cases=1;cases<=N;cases++){ char GameName[MAX_SIZE]; char Name[MAX_SIZE]; Team team[MAXD]; int n; gets(GameName); scanf("%d",&n);/*队伍个数*/ getchar(); for(int i=0;i<n;i++){/*加名字顺便初始化*/ gets(Name); strcpy(team[i].name,Name); team[i].win =0; /*胜利场数*/ team[i].lose =0; /*失败场数*/ team[i].tie =0; /*平均场次*/ team[i].player=0; /*总共比赛场次*/ team[i].Get =0; /*得球*/ team[i].Lost =0; /*失球*/ } int m; scanf("%d",&m);/*输入比赛的场次*/ getchar(); char Game[MAX_SIZE]; for(int i=0;i<m;i++){ memset(Game,0,sizeof(Game)); gets(Game); /*先提取得分*/ char *p1=strchr(Game,'#'); char *p2=strchr(Game,'@'); char *p3=strchr(p1+1,'#'); int point1; int point2; sscanf(p1+1,"%d",&point1); sscanf(p2+1,"%d",&point2); /*已经将分数提取出来了*/ *p1='\0'; /*队名也提取完毕了*/ /*下面开始找队伍*/ int x;int y;/*记录队伍*/ for(int i=0;i<n;i++){ if(strcmp(Game,team[i].name)==0) x=i; else if(strcmp(p3+1,team[i].name)==0) y=i; } /*下面判断情况*/ if(point1>point2){ team[x].win++; team[y].lose++; } else if(point1<point2){ team[x].lose++; team[y].win ++; } else if(point1==point2){ team[x].tie++; team[y].tie++; } team[x].Get +=point1; team[x].Lost+=point2; team[x].player++; team[y].Get +=point2; team[y].Lost+=point1; team[y].player++; } for(int i=0;i<n;i++){ team[i].score=3*team[i].win+1*team[i].tie; team[i].Get_Lost=team[i].Get-team[i].Lost; } sort(team,team+n,cmp); printf("%s\n",GameName); for(int i=0;i<n;i++) printf("%d) %s %dp, %dg (%d-%d-%d), %dgd (%d-%d)\n",i+1,team[i].name,team[i].score,team[i].player,team[i].win,team[i].tie,team[i].lose,team[i].Get_Lost,team[i].Get,team[i].Lost); if(cases<N) printf("\n"); } return 0;}
0 0
- Football (aka Soccer) -uva10194 模拟题
- UVA10194 - Football (aka Soccer)
- UVa10194 Football (aka Soccer)
- UVA10194 Football (aka Soccer)
- UVA10194 Football (aka Soccer) 排序
- UVa 10194 Football (aka Soccer) (模拟)
- Football (aka Soccer)
- 10194 - Football (aka Soccer)
- 10194 - Football (aka Soccer)
- 10194 - Football (aka Soccer)
- 110408 Football (aka Soccer)
- 10194 - Football (aka Soccer)
- UVA Football (aka Soccer)
- 10194 - Football (aka Soccer)
- Football (aka Soccer)
- UVA 10194 Football (aka Soccer) 足球成绩统计 检索+模拟
- uva 10194 Football (aka Soccer)
- UVa 10194 - Football (aka Soccer)
- 第五周作业——有向图邻接表表示及反向图构造
- 并发框架Disruptor
- 烟雨落花葬足下,流云千里诉相思。
- 龙书笔记(4)
- 未能写入输出文件“c:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temp\App_global.asax.lra4cdoj.dll' -- '拒绝访问
- Football (aka Soccer) -uva10194 模拟题
- JSP中动态INCLUDE与静态INCLUDE的区别
- 30 查看当前Linux系统中安装的shell及其版本
- 惹恼程序员的十件事
- Android完全退出多个activity程序
- POJ-3009
- 【史上最坑爹的游戏】002 关卡选择画面的实现
- Error 1962: No operating system found.
- IE6浏览器退役留下22%市场空白,正待分食