You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
81 lines
2.5 KiB
81 lines
2.5 KiB
1 year ago
|
#include <iostream>
|
||
|
#include <fstream>
|
||
|
#include <sstream>
|
||
|
#include <vector>
|
||
|
#include <algorithm>
|
||
|
|
||
|
std::string slurp(std::ifstream& in) {
|
||
|
std::ostringstream sstr;
|
||
|
sstr << in.rdbuf();
|
||
|
return sstr.str();
|
||
|
}
|
||
|
|
||
|
struct ScoreData{
|
||
|
int difficulty=0;
|
||
|
std::string song;
|
||
|
int totalEX=0;
|
||
|
int ex1=0,ex2=0,ex3=0;
|
||
|
std::string str()const{
|
||
|
return "["+std::to_string(difficulty)+"] "+song+": "+std::to_string(totalEX)+" total, "+" EX1: "+std::to_string(ex1)+" EX2: "+std::to_string(ex2)+" EX3: "+std::to_string(ex3);
|
||
|
}
|
||
|
friend std::ostream&operator<<(std::ostream&os,const ScoreData&data){
|
||
|
os<<data.str();
|
||
|
return os;
|
||
|
}
|
||
|
};
|
||
|
|
||
|
std::string GetNext(int&marker,std::string str){
|
||
|
int originalMarker=marker;
|
||
|
marker=str.find_first_of(',',originalMarker)+1;
|
||
|
return str.substr(originalMarker,marker-1);
|
||
|
};
|
||
|
|
||
|
int main(){
|
||
|
std::vector<ScoreData>dataA,dataB;
|
||
|
std::vector<std::pair<int,int>>player1Score,player2Score,player3Score;
|
||
|
std::ifstream file("team.csv");
|
||
|
std::string line;
|
||
|
//First two lines are garbage data.
|
||
|
std::getline(file,line);
|
||
|
std::getline(file,line);
|
||
|
for(int i=0;i<12;i++){
|
||
|
std::getline(file,line);
|
||
|
int marker=0;
|
||
|
ScoreData dat{
|
||
|
stoi(GetNext(marker,line)),
|
||
|
GetNext(marker,line),
|
||
|
stoi(GetNext(marker,line)),
|
||
|
stoi(GetNext(marker,line)),
|
||
|
stoi(GetNext(marker,line)),
|
||
|
stoi(GetNext(marker,line))};
|
||
|
player1Score.emplace_back(std::pair<int,int>{dat.ex1,0});
|
||
|
player2Score.emplace_back(std::pair<int,int>{dat.ex2,0});
|
||
|
player3Score.emplace_back(std::pair<int,int>{dat.ex3,0});
|
||
|
dataA.emplace_back(dat);
|
||
|
}
|
||
|
//Two more lines of garbage data.
|
||
|
std::getline(file,line);
|
||
|
std::getline(file,line);
|
||
|
for(int i=0;i<12;i++){
|
||
|
std::getline(file,line);
|
||
|
int marker=0;
|
||
|
ScoreData dat{
|
||
|
stoi(GetNext(marker,line)),
|
||
|
GetNext(marker,line),
|
||
|
stoi(GetNext(marker,line)),
|
||
|
stoi(GetNext(marker,line)),
|
||
|
stoi(GetNext(marker,line)),
|
||
|
stoi(GetNext(marker,line))};
|
||
|
player1Score[i].second=dat.ex1;
|
||
|
player2Score[i].second=dat.ex2;
|
||
|
player3Score[i].second=dat.ex3;
|
||
|
dataB.emplace_back(dat);
|
||
|
}
|
||
|
std::cout<<"File Contents:"<<std::endl<<std::endl;
|
||
|
for(auto&list:{dataA,dataB}){
|
||
|
for(auto&dat:list){
|
||
|
std::cout<<dat<<std::endl;
|
||
|
}
|
||
|
}
|
||
|
std::cout<<"==================="<<std::endl;
|
||
|
}
|