杭电1225 Football Score (结构体排序)
来源:互联网 发布:mysql导出表结构 编辑:程序博客网 时间:2024/05/21 07:57
Football Score
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 2585 Accepted Submission(s): 729
Here are the rules:
1 Every team has to match with all the other teams.
2 Every two teams have to match for two times,one at home and one away.
3 In one match, the winner will get 3 points, the loser will get 0 point. If it is draw, both of them will get 1 point.
Process to the end of file.
Output a blank line after each test case.
3Manchester VS Portsmouth 3:0Liverpool VS Manchester 1:1Liverpool VS Portsmouth 0:0Portsmouth VS Manchester 1:1Manchester VS Liverpool 2:1Liverpool VS Portsmouth 1:2
Manchester 8Portsmouth 5Liverpool 2Huge input, scanf is recommended.HintHint
/*
#include<stdio.h>
#include<string.h>
#include<algorithm>
using std::sort;
#define maxn 10000
#define MAN 100
struct foot{
int score;
int net;
int kickin;
int lost;
char name[50];
};
struct foot s[maxn];
/*
int find(char str[], int k){
for(int i = 0; i < k; ++i)
if(!strcmp(str, s[i].name)) return i;
return -1;
}
*/
int find(char name0[] ,int k)
{
int j;
for(j=0;j<k;j++)
if(strcmp(s[j].name,name0)==0)return j;
return -1;
}
bool cmp(foot a,foot b)
{
if(a.score>b.score) return 1;
if(a.score==b.score&&a.net>b.net) return 1;
if(a.score==b.score&&a.net==b.net && a.kickin>b.kickin) return 1;
if(a.score==b.score && a.net==b.net && a.kickin==b.kickin && strcmp(a.name,b.name)<0 ) return 1;
return 0;
}
int main()
{
int N,n;
int i,a,b;
int kickin1,lost1;
char name1[MAN], name2[MAN];
while(scanf("%d",&n)!=EOF)
{
int num=0;
memset(s,0,sizeof(s));
for( i=0;i<n*(n-1);i++)
{
scanf("%s VS %s %d:%d",name1,name2,&kickin1,&lost1 );
// int sign=kickin1-lost1;
if(kickin1>lost1){a=3;b=0;}
else if(kickin1==lost1){a=1;b=1;}
else{a=0;b=3;}
int x=find(name1,num);
// printf("x= %d \n",x);
if(x!=-1)
{
s[x].kickin+=kickin1;
s[x].lost+=lost1;
s[x].score+=a;
// printf(" %dth score%d\n",x,s[x].score);
// s[x].net+=sign;
}
else
{
strcpy(s[num].name,name1);
s[num].kickin+=kickin1;
s[num].lost+=lost1;
s[num].score+=a;
// printf("%dth score %d\n",num,s[num].score);
// s[num].net+=sign;
num++;
}
int y=find(name2,num);
// printf("y= %d \n",y);
if(y!=-1)
{
s[y].kickin+=lost1;
s[y].lost+=kickin1;
s[y].score+=b;
// printf(" %dth score%d\n",y,s[y].score);
// s[y].net-=sign;
}
else
{
strcpy(s[num].name,name2);
s[num].kickin+=lost1;
s[num].lost+=kickin1;
s[num].score+=b;
// printf(" %dth score %d\n",num,s[num].score);
// s[num].net-=sign;
num++;
}
}
for(int i=0;i<n;i++)
s[i].net=s[i].kickin-s[i].lost;
sort(s,s+n,cmp);
for(int i=0;i<n;i++)
printf("%s %d\n",s[i].name,s[i].score);
printf("\n");
}
return 0;
}
*/
- 杭电1225 Football Score (结构体排序)
- 【杭电oj】1225 - Football Score(结构体排序)
- HDOJ 1225 Football Score(结构体排序)
- 杭电 1225 Football Score
- HDU1225 Football Score 【结构体排序】
- hdu 1225 Football Score
- HDU-1225-Football Score
- HDU 1225 Football Score
- hdoj 1225 Football Score
- HDU-1225-Football Score
- uva 10194 Football (字符结构体排序)
- Football Score
- hdu 1225 Football Score
- hdu 1225 Football Score
- 【杭电oj】1872 - 稳定排序(结构体排序)
- 杭电2534-Score
- 杭电-5499SDOI(结构体排序)
- 【杭电oj】5499 - SDOI(结构体排序,水)
- 二进制转十进制--字符串转换成整形变量---位操作----编程随笔(5)
- getMeasuredHeight(),getScrollY(),getHeight()的区别和联系
- 相同的生命周期
- Android程序启动初始画面的实现
- 关于c语言的输入函数问题
- 杭电1225 Football Score (结构体排序)
- 排序算法之希尔排序
- zlib编译
- Read a whole file into a string in C++
- CentOS-6.4-DVD系统中安装Oracle-11.2.0.4
- linux 的date命令及系统时间设置
- hdu 1059 Dividing
- set集合特点级子类的特点
- 将java的console日志写入文件