赞
踩
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <stdlib.h>
using namespace std;
string stander("C,I,R,U,E");
typedef struct contest
{
int m_index;//队伍
int m_dequeIndex;//题目编号
int m_timer;//时间
string m_state;//状态
}InfoContest;
typedef struct resultData
{
int m_index;//队伍
int m_sumSubject;//题目总数
int m_sumTime;//总时间
}ResultData;
#define M 100
int resultIndex = 0;
vector<InfoContest> g_source;
ResultData g_dest[M];
vector<ResultData> g_destResult;
void create()
{//测试数据
InfoContest t1;
t1.m_index = 1;
t1.m_dequeIndex = 2;
t1.m_timer = 10;
t1.m_state = string("I");
g_source.push_back(t1);
InfoContest t2;
t2.m_index = 3;
t2.m_dequeIndex = 1;
t2.m_timer = 11;
t2.m_state = string("C");
g_source.push_back(t2);
InfoContest t3;
t3.m_index = 1;
t3.m_dequeIndex = 2;
t3.m_timer = 19;
t3.m_state = string("R");
g_source.push_back(t3);
InfoContest t4;
t4.m_index = 1;
t4.m_dequeIndex = 2;
t4.m_timer = 21;
t4.m_state = string("C");
g_source.push_back(t4);
InfoContest t5;
t5.m_index = 1;
t5.m_dequeIndex = 1;
t5.m_timer = 25;
t5.m_state = string("C");
g_source.push_back(t5);
}
bool Comp(const InfoContest &a,const InfoContest &b)
{
return a.m_index < b.m_index ;
}
void qSort()
{//按选手编号从小到大排序
sort(g_source.begin(), g_source.end(), Comp);
}
void find()
{//过滤
int tempIndex = 0;
for (int i = 0;i < g_source.size();i++)
{
for (int j = i;j < g_source.size(); j++)
{
if (g_source[i].m_index == g_source[j].m_index)
{
if (g_source[j].m_state == "I")
{
g_dest[resultIndex].m_index = g_source[j].m_index;
g_dest[resultIndex].m_sumTime +=20;
tempIndex = j;
}
else if (g_source[j].m_state == "C")
{
g_dest[resultIndex].m_index = g_source[j].m_index;
g_dest[resultIndex].m_sumSubject++;
g_dest[resultIndex].m_sumTime +=g_source[j].m_timer;
tempIndex = j;
}
}
}
g_destResult.push_back(g_dest[resultIndex]);
resultIndex++;
i = tempIndex;
}
}
bool Comp1(const ResultData &a,const ResultData &b)
{//题目数降序
return a.m_sumSubject < b.m_sumSubject ;
}
bool Comp2(const ResultData &a,const ResultData &b)
{//时间升序
return a.m_sumTime > b.m_sumTime ;
}
//打印
void shown()
{
sort(g_destResult.begin(), g_destResult.end(), Comp1);//题目数降序
sort(g_destResult.begin(), g_destResult.end(), Comp2);//时间升序
for (int i = 0;i < g_destResult.size();++i)
{
cout<<g_destResult[i].m_index<<endl;
cout<<g_destResult[i].m_sumSubject<<endl;
cout<<g_destResult[i].m_sumTime<<endl;
}
}
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。