// ===================================================================================== // // Filename: stat.cc // // Description: read one result // // Version: 1.0 // Created: 2018年 03月 16日 星期五 22:02:12 CST // Revision: none // Compiler: g++ // // Author: Jinkun Lin, jkunlin@gmail.com // Organization: School of EECS, Peking University // // ===================================================================================== #include #include #include #include using namespace std; int main(int argc, char const *argv[]) { if (argc != 2) { return 1; } string filename = argv[1]; ifstream infile(filename); if (!infile) { std::cout << "file" << std::endl; return 1; } size_t b = filename.find_last_of('_') + 5; size_t e = filename.find_last_of('.'); string seed = filename.substr(b, e - b); double cutoff = 120; string line, tmp; int size, old_size = 0; double time, old_time = 0; char exact = 'h'; while (getline(infile, line)) { istringstream is(line); is >> tmp >> size >> time; if (time > cutoff) { size = old_size; time = old_time; } else { old_size = size; old_time = time; } } std::cout << seed << '\t' << size << '\t' << time << '\t' << exact << std::endl; return 0; }