HDU-1225 Football Score
http://acm.hdu.edu.cn/showproblem.php?pid=1225
一道超级简单的题,就因为我忘记写return,就wa好久,拜托我自己细心一点。
学习的地方:不过怎么查找字符串并返回下标
Football Score
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 2739 Accepted Submission(s): 785
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.
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int t;
struct node
{
char name[];
int kick;
int net;
int score;
}a[];
bool cmp(node b,node c)
{
if(b.score==c.score)
{
if(b.net==c.net)
{
if(b.kick==c.kick)
return strcmp(b.name,c.name)<?:; else
return b.kick>c.kick;
}
else
return b.net>c.net;
}
else
return b.score>c.score;
}
int find(char ss[]) //查找字符串并返回下标
{
int i;
if(t==-)
{
strcpy(a[].name,ss);
t=;
return t;
}
for(i=;i<=t;i++)
if(strcmp(a[i].name,ss)==)
return i;
t++;
strcpy(a[t].name,ss);
return t;
}
int main()
{
int n,i,x,y,p,q;
char str1[],str2[],str3[];
while(~scanf("%d",&n))
{
t=-;
memset(a,,sizeof(a));
for(i=;i<=n*(n-);i++)
{
scanf("%s",str1);
x=find(str1);
scanf("%s",str2);
scanf("%s",str3);
y=find(str3);
scanf("%d:%d",&p,&q);
a[x].kick+=p;
a[x].net+=p-q;
a[y].kick+=q;
a[y].net+=q-p;
if(p>q)
a[x].score+=;
else if(q>p)
a[y].score+=;
else
{
a[x].score+=;
a[y].score+=;
}
}
sort(a,a+t+,cmp);
for(i=;i<=t;i++)
{
printf("%s %d\n",a[i].name,a[i].score); }
printf("\n"); }
return ;
}
HDU-1225 Football Score的更多相关文章
- 【HDOJ】1225 Football Score
这种结构体排序的题,十分容易考上机题,qsort+结构体解决.马上就要机考了,多练习一下这样的题目也好. #include <stdio.h> #include <string.h& ...
- HDU 5873 Football Games 【模拟】 (2016 ACM/ICPC Asia Regional Dalian Online)
Football Games Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)To ...
- HDOJ(HDU) 2309 ICPC Score Totalizer Software(求平均值)
Problem Description The International Clown and Pierrot Competition (ICPC), is one of the most disti ...
- HDU 5873 Football Games(竞赛图兰道定理)
http://acm.hdu.edu.cn/showproblem.php?pid=5873 题意: 现在有比赛,所有队伍两两进行比赛,赢的积2分,输的积0分,如果平局的话就各自都积1分,现在给出每只 ...
- HDU-1225 Football Score 模拟问题(水题)
题目链接:https://cn.vjudge.net/problem/HDU-1225 水题 代码 #include <algorithm> #include <string> ...
- HDU 5873 Football Games
随便判了几个条件就过了,也不知道对不对的. 正解应该是: $[1].$${s_1} + {s_2} + {s_3} + ...... + {s_n} = n(n - 1)$ $[2].$${s_1} ...
- 2019的hdu暑假作业(欢迎纠错)
1219 遍历计数. #include<bits/stdc++.h> #define QAQ 0 using namespace std; ]; ]; int main(){ )){ me ...
- CHAPTER 40 Science in Our Digital Age 第40章 我们数字时代的科学
CHAPTER 40 Science in Our Digital Age 第40章 我们数字时代的科学 The next time you switch on your computer, you ...
- 2019.12.12 Java的多线程&匿名类
Java基础(深入了解概念为主) 匿名类 定义 Java匿名类很像局部或内联系,只是没有明细.我们可以利用匿名类,同时定义并实例化一个类.只有局部类仅被使用一次时才应该这么做. 匿名类不能有显式定义的 ...
随机推荐
- Spring JdbcTemplate批量操作数据库
个人总结,转载请注明出处:http://www.cnblogs.com/lidabnu/p/5769732.html 还是分两部分:解决什么问题和怎么做. 解决什么问题 提升数据操作性能,因为批量操作 ...
- 规划收发你的邮件,使用qq邮箱接收阿里云企业邮邮件
使用qq邮箱接收阿里企业邮 首先管理员开通企业邮后会发来激活短信 根据短信提示打开https://qiye.aliyun.com企业邮登陆地址 使用短信提供的密码登陆邮箱 首次登陆时会让我们重设密码 ...
- 多个互相有联系的checkbox的单选逻辑
checkbox单选的状态逻辑,状态好的时候一下就写好了,状态不好的时候要调试比较久,当然主要是对其中的事件不太清楚. 先给出效果图吧. 然后给出代码, selectZhiFuBaoPay.setOn ...
- SQL输出矩阵
数据库环境:SQL SERVER2008R2 需求:用SQL实现如下2个图中的矩阵. 图1和图2都是行列转换的另一个变形,下面直接贴上SQL脚本. 图1的SQL实现 /*利用系统 ...
- NSdate 时间格式
NSdate 时间格式 NSTimeInterval 时间间隔 基本单位 秒 NSDateFormatter 时间格式器 用于日期对象的格式化或字符串解析为日期对象 日期格式如下: y 年 M 年 ...
- C++关于编译器合成的默认构造函数
有两个常见的误解: 1.任何类如果没有定义默认构造函数,就会被合成出一个来. 2.编译器合成的默认构造函数会显式地设定类内每一个数据成员的默认值. 对于第一个误解,并不是任何类在没有显式定义默认构造函 ...
- 一个在线的C++帮助文档网站 转载
http://www.cplusplus.com/ //C++参考 http://www.cppreference.com/wiki/start //C++参考 http ...
- JS-SDK微信支付开发攻略
一.吐槽篇 一个字——坑!两个字——很坑!三个字——非常坑!首先,微信支付接口作为微信开发接口的一部分,竟然有一本书那么厚的官方文档,共36页,更重要的是,这36页还不能把开发的流程说清楚,描述过于分 ...
- 实现Action(含Action访问ServletAPI)
Action里是否包含实例变量不重要,重要的是包含setter和getter方法. Action可用于封装请求参数和处理结果.jsp中使用struts2输出:<s:property value= ...
- WAMP(Windows+Apache+Mysql+PHP)环境搭建
学习PHP已经有一段时间,一直没有写过关于开发环境搭建的笔记,现在补上吧,因为安装配置的步骤记得不是很清楚,借鉴了一些别人的经验,总结如下: 首先去官方网站下载各个软件,下载需要的版本: Apache ...