球队比分
题目: 输入球队数量,球队之间将进行比赛,胜利者积分+3,打平则+1,失败则+0。最终按球队积分以及净胜球进行排序。
思路: 定义结构体,成员有球队名、球队积分、球队净胜球。利用随机数生成比赛得分,随后根据比分计算双方球队积分、净胜球情况。最后按照积分-净胜球进行排序。
#include "stdafx.h"
#include <string>
#include <iostream>
#include <cstdlib>
#include <ctime>
#include <algorithm>
#include "GameScore.h"
using namespace std;
template <class T>
int getArrLen(T& array)
{
return (sizeof(array)/sizeof(array[0]));
}
int cmp(Team a, Team b)
{
return (a.Credit > b.Credit || (a.Credit == b.Credit && a.NetScore