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匿名类很像局部或内联系,只是没有明细.我们可以利用匿名类,同时定义并实例化一个类.只有局部类仅被使用一次时才应该这么做. 匿名类不能有显式定义的 ...
随机推荐
- 请问JAVA三层架构,持久层,业务层,表现层,都该怎么理解?和MVC三层模型有什么区别
持久层用来固化数据,如常说的DAO层,操作数据库将数据入库业务层用来实现整体的业务逻辑 如 前台获得了数据,逻辑层去解析这些数据,效验这些数据等操作表现层很好解释 你现在看到的网页 一些界面 都属于 ...
- CSS-BFC
最近看幕课网CSS之Float,float最初是为了实现文字的环绕效果:这里面提到BFC,刚好项目中正用到一种解决BFC的方法,DIV在添加float后,就不存在文档流中啦,不占据空间,这使的一些未浮 ...
- Oracle 11g-R2 SQL Developer连接MSSQL2008
操作系统环境:WINDOWS8.1 工具: Oracle 11g-R2 SQL Developer 网络资源:http://sourceforge.net/project/showfiles.php ...
- shell脚本学习之Bash shell 里各种括号的用法
今天在 SegmentFault 上看到又有人问起关于Shell里各种括号的问题.对于很多玩Shell的人,括号是个很尴尬的问题,用起来没问题,说起来不明白,我在这里总结一下Bash Shell几种括 ...
- 关于php的一些开源程序
最好用的当属thinksns,目前更新到4.3.4, 社交型网站. 此网站提供大量源码,有时间可以去看看:http://down.admin5.com/
- Gherkin学习笔记
前言 由于项目准备使用BDD模式开发,所以最近在学习BDD,同时也记录下自己的学习点滴. 参考原文:https://github.com/cucumber/cucumber/wiki/Gherkin ...
- 子网/ip/子网掩码
IP地址由网络地址和主机地址组成 而现在IP由“子网掩码”通过子网网络地 址细分出 A,B,C类更小的网络.这种方式 实际上就是将原来的A类,B类,C类等分类 中的的主机地址部分用作子网地址,可以 将 ...
- DevExpress GridControl 中下拉框联动效果的实现(及支持文本框录入情况)
先解释一下标题: grid中的某一列默认为文本框,根据需要动态的变更为下拉框,且支持动态变更数据源 需求是这样的: 有一些参数(A),这些参数又分别对应另外的参数(B),所以,先把A作为一列,B根据A ...
- javascript动态添加效果
<script type="text/javascript"> window.onload=function(){ $("#ch").click(f ...
- php 扩展编译linux
进入扩展库目录:$cd phpredis-master 需要root权限执行 执行:$ phpize 执行:$ ./configure 执行:$ make 执行:$ make install 编译 ...