10194 - Football (aka Soccer)

2024-08-24 04:58
文章标签 football soccer aka 10194

本文主要是介绍10194 - Football (aka Soccer),希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

题目:10194 - Football (aka Soccer)


题目大意:给你一些比赛记录,然后让你依据要求这些排序:

  1. Most points earned. (得分胜利3,平局1,失败0)
  2. Most wins.
  3. Most goal difference (i.e. goals scored - goals against)
  4. Most goals scored.
  5. Less games played.    (比赛次数越少越好)
  6. Lexicographic order. (不区分大小写排序)
  7. 解题思路:就是按照这些要求写比较函数,用sort排序,然后输出即可。注意:scanf()是不舍弃回车,需要ch = getchar()接受回车,而gets或getline是可以舍弃回车的。然后要细心。数组不要越界,越界了不仅可能RE还有可能WA。两个数据组之间要有一个空白行。

  1. #include<stdio.h>
    #include<string>
    #include<string.h>
    #include<stdlib.h>
    #include<iostream>
    #include<algorithm>
    using namespace std;const int N = 105;
    const int T = 35;
    const int M = 1005;char tourname[N], team[T][T], record[M][N];
    int n, t, g;class RANK{public:RANK () { strcpy(name, ""); totalp = gameplay = win = tie = loss = different = score = against = 0;}char name[T];int totalp;int gameplay;int win; int tie;int loss;int different;int score;int against;void clear() {strcpy(name, ""); totalp = gameplay = win = tie = loss = different = score = against = 0;}} rank[T];void change(char *s) {for(int i = 0; i < strlen(s); i++) {if(s[i] >= 'A' && s[i] <= 'Z')s[i] += 32;}
    }bool cmp(const RANK &a, const RANK &b) {if(a.totalp > b.totalp)return true;else if(a.totalp < b.totalp)return false;if(a.win > b.win)return true;else if(a.win < b.win)return false;if (a.different > b.different)return true;else if(a.different < b.different)return false;if(a.score > b.score)return true;else if(a.score < b.score)return false;if(a.gameplay < b.gameplay)return true;else if(a.gameplay > b.gameplay)return false;char str1[T], str2[T];strcpy(str1, a.name);strcpy(str2, b.name);change(str1);change(str2);if(strcmp(str1, str2) < 0)return true;elsereturn false;
    }void ranked () {int i, j, k, l, bo;for( i = 0; i < g; i++) {char nam1[T],nam2[T], s1[5], s2[5];k = bo = 0;for( j = 0; j < strlen(record[i]); j++) {if(!bo && record[i][j] != '#')nam1[k++] = record[i][j];else if(!bo){nam1[k] = '\0';k = 0;bo = 1;j++;}if(bo && record[i][j] != '@')s1[k++] = record[i][j];else if(bo){s1[k] = '\0';k = 0;break;}}l = bo = 0;for(k = j + 1; k < strlen(record[i]); k++) {if(!bo &&record[i][k] != '#')s2[l++] = record[i][k];else if(!bo){s2[l] = '\0';l = 0;bo = 1;}if(bo && record[i][k] != '#') nam2[l++] = record[i][k];}nam2[l] = '\0';int a, b;a = atoi(s1);b = atoi(s2);for(j = 0; j < t; j++) {if(strcmp(rank[j].name, nam1) == 0) {rank[j].gameplay++;rank[j].score += a;rank[j].against += b;if(a > b) {rank[j].win++;rank[j].totalp += 3;}else if(a < b)rank[j].loss++;else {rank[j].totalp += 1;rank[j].tie++;}break;}}for(j = 0; j < t; j++) {if(strcmp(rank[j].name, nam2) == 0) {rank[j].gameplay++;rank[j].score += b;rank[j].against += a;if(a < b) {rank[j].win++;rank[j].totalp += 3;}else if(a > b) rank[j].loss++;else {rank[j].totalp += 1;rank[j].tie++;}break;}}}for (i = 0; i < t; i++) rank[i].different = rank[i].score - rank[i].against;
    }int main() {int i;char ch;scanf("%d", &n);ch = getchar();while (n--) {cin.getline(tourname, N);scanf("%d", &t);ch = getchar();for (i = 0; i < t; i++) {cin.getline(team[i], T);}scanf("%d", &g);ch = getchar();for (i = 0; i < g; i++) {cin.getline(record[i], N);}for(i = 0; i < t; i++)strcpy(rank[i].name, team[i]);ranked();sort(rank, rank + t, cmp);printf("%s\n",tourname);for(i = 0; i < t; i++) printf("%d) %s %dp, %dg (%d-%d-%d), %dgd (%d-%d)\n", i+1, rank[i].name, rank[i].totalp, rank[i].gameplay, rank[i].win, rank[i].tie, rank[i].loss, rank[i].different, rank[i].score, rank[i].against);if(n)printf("\n");memset(team, 0, sizeof(team));memset(record, 0, sizeof(record));for(i = 0; i < t; i++)rank[i].clear();}return 0;
    }


这篇关于10194 - Football (aka Soccer)的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/1101513

相关文章

UVALIVE 4887 Soccer UVELIVE 4882

2015 UESTC Winter Training #6 训练赛的两道搜索模拟题 uvalive 4882 // whn6325689// Mr.Phoebe// http://blog.csdn.net/u013007900#include <algorithm>#include <iostream>#include <iomanip>#include

Codeforces #246 (Div. 2) B. Football Kit

题意是:有n个队伍,每个队伍有主场衣服颜色x[i] 客场衣服颜色y[i] 每个队都要作为主场和另外n-1支客场队进行比赛 在这之中如果主场衣服和另一队的客场衣服颜色相同 那么客场队就换上自己的主场衣服(保证主场 客场衣服颜色不同) 最后输出每个队使用主场衣服和客场衣服的次数 开始的做法是暴力,因为n最大有10的5次方,当时想到会超时,但是看到那么多人写出来 想着不会很复杂啊,结果

UVa - 10194 - Train Swapping

啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦        怀着无比激动的心情。   某大神助攻。 不然就废了 收:strcasecmp(s1, s2);  题目大意: 多支队伍比赛。 记录每支队伍 1总共赢的分数(赢了得3分,平得1分,输不得分) 2共比赛的场数 3共赢的常数 4共平的场数 5共输的场数 6赢球数与输球数之差 7共赢的球数(输的场中

cannot initialize a parameter of type 'jboolean *' (aka 'unsigned char *') with an rvalue of type...

cannot initialize a parameter of type 'jboolean *' (aka 'unsigned char *') with an rvalue of type 'bool' 错误代码 const char *jstringTocharArray(JNIEnv *env, jstring str) {return env->GetStringChars(str,

Think I’ll Buy Me a Football Team-2924

题目:http://acm.hdu.edu.cn/showproblem.php?pid=2924 代码: #include<iostream>using namespace std;int main(){int num=0,fsum=0,lsum=0,k=1;while(cin>>num&&num!=0){int **p=new int*[num];for(int i=0;i<num;

Codeforces 1244 C. The Football Season —— 扩展欧几里得

This way 题意: 让你求dx+wy+0z=p,[0<=x,y,z&&x+y+z=n] 题解: 首先很明显可以暴力,因为d和w都是<=1e5的,所以枚举1e5次必然能出答案。 但是我们在学习新知识,所以必然不能这样子去简单地暴力,要搞一点数学的东西进去。 那么很明显是扩展欧几里得,但是裸的板子会有负数的情况,所以我们需要先贪心地放赢得局,因为这样子前两种局数会达到最小,然后剩下的再

报错lsSocket.cpp:35:7: error: invalid use of incomplete type ‘SSL {aka struct ssl_st}’

/erizo/src/erizo/dtls/DtlsSocket.cpp:35:7: error: invalid use of incomplete type ‘SSL {aka struct ssl_st}’    mSsl->ctx = mContext;        ^~ In file included from /home/test/.cache/node-gyp/12.14.1/i

强化学习-google football 实验记录

google football 实验记录 1. gru模型和dense模型对比实验 实验场景:5v5(控制蓝方一名激活球员),跳4帧,即每个动作执行4次 实验点: 修复dense奖励后智能体训练效果能否符合预期 实验目的: 对比gru 长度为16 和 dense net作为aggrator的区别 实验效果 reward google football 实验记录 1. gru模型

error: style attribute 'attr/colorPrimary (aka com.ab.activity:attr/colorPrimary)' not found.

compileSdkVersion 修改为28 添加如下依赖implementation 'androidx.appcompat:appcompat:1.0.0-alpha1'implementation 'androidx.constraintlayout:constraintlayout:1.1.2'

paip invalid conversion from FormWdg to SOCKET {aka unsigne

分享一下我老师大神的人工智能教程!零基础,通俗易懂!http://blog.csdn.net/jiangjunshow 也欢迎大家转载本篇文章。分享知识,造福人民,实现我们中华民族伟大复兴! paip.invalid conversion from FormWdg* to SOCKET {aka unsigned int} 作者Attilax ,  EMAIL:1466519819