/* Used in conjunction with the honn network and the evalimage script, /* this program sorts the image rankings and outputs the first 20. */ #include #include #include int main(int argc, char *argv[]) { istream *pIn = &cin; ifstream infile; if(argc > 1) { infile.open(argv[1]); if(!infile.is_open()) { cerr << "Couldn't open input file.\n"; return 1; } pIn = &infile; } unsigned short numWinners = 20; unsigned short length = 59; unsigned short elementIndex; struct { char pFile[100]; double score; } pElement[length]; for(unsigned short elementIndex=0; elementIndex> pElement[elementIndex].pFile; // read the filename (*pIn) >> pElement[elementIndex].pFile; // read the score (*pIn) >> pElement[elementIndex].score; } for(unsigned short winnerIndex = 0; winnerIndex < numWinners; winnerIndex++) { double highestScore = -1E10; unsigned short highestElement; for(unsigned short elementIndex=0; elementIndex highestScore) { highestScore = pElement[elementIndex].score; highestElement = elementIndex; } } cout << pElement[highestElement].pFile << '\n' << highestScore << "\n\n"; pElement[highestElement].score = 1E-10; } }