JOI2008-2009をC++で解いてみた2問目

#include <iostream>
#include <fstream>
#include <stdlib.h>
#include <algorithm>
#include <vector>

using namespace std;

class Result{
    vector<int> scores;
    public:
    Result(){
        for(int i=0; i<4; i++){
            scores.push_back(0);
        }
    }
    void append(int n){
        scores.pop_back();
        scores.push_back(n);
        sort(scores.begin(), scores.end());
        reverse(scores.begin(), scores.end());
    }
    int calc(){
        return scores[0] + scores[1] + scores[2];
    }
    int haku(){
        vector<int>::iterator iter;
        for(iter=scores.begin(); iter != scores.end(); iter++){
            cout << *iter << endl;
        }
    }
};

int main(int argc, char* argv[]){
    //in
    ifstream ifs(argv[1]);
    int numline = 0;
    Result* waseda = new Result();
    Result* keio = new Result();
    string buf;
    while(getline(ifs, buf)){
        numline++;
        if(numline <= 10){
            waseda->append(atoi(buf.c_str()));
        }else{
            keio->append(atoi(buf.c_str()));
        }
    }
    cout << waseda->haku() << endl;
    cout << keio->haku() << endl;
    cout << waseda->calc() << " " << keio->calc() << endl;
    //out
    ofstream ofs((string(argv[1]) + string("_out.txt")).c_str());
    ofs << waseda->calc() << " " << keio->calc() << endl;
    delete waseda;
    delete keio;
    return 0;
}

(`・ω・´)
比較的うまく書けた