ResultProcessor::ResultProcessor(std::string path , int pprocNum) { oneclickLogger << FileLogger::LOG_INFO << "started processing results\n\n"; initPProcessor(pprocNum); std::string algName; std::vector<std::string> configPaths; std::vector<std::string> logPaths; std::vector<std::string> dirPaths; getDirectoryPaths(path , dirPaths); for (unsigned i = 0 ; i < dirPaths.size() ; i++) { //Creates directory logger. All directory specific info are logged here also. FileLogger * dirLogger = new FileLogger(dirPaths[i] + "/experiment.log"); oneclickLogger << FileLogger::LOG_INFO << "processing experiment: " << Utils::getLastItemInPath(dirPaths[i]) << "\n"; *dirLogger << FileLogger::LOG_INFO << "processing experiment: " << Utils::getLastItemInPath(dirPaths[i]) << "\n"; //Getting paths to all logs and configs in subdirectories getFilePaths(dirPaths[i], configPaths, INDEX_CONFIG); sortStrings(configPaths); getFilePaths(dirPaths[i], logPaths, INDEX_EACIRC); sortStrings(logPaths); oneclickLogger << FileLogger::LOG_INFO << Utils::itostr(configPaths.size()) << " configs and " << Utils::itostr(logPaths.size()) << " logs in experiment\n"; *dirLogger << FileLogger::LOG_INFO << Utils::itostr(configPaths.size()) << " configs and " << Utils::itostr(logPaths.size()) << " logs in experiment\n"; //Check for config consistency, won't procceed otherwise oneclickLogger << FileLogger::LOG_INFO << "checking differences in configuration files\n"; *dirLogger << FileLogger::LOG_INFO << "checking differences in configuration files\n"; if(checkConfigs(configPaths , algName , dirLogger)) { //Checks errors and warnings, if okay run PostProcessor oneclickLogger << FileLogger::LOG_INFO << "processing results, checking errors/warnings in logs\n"; *dirLogger << FileLogger::LOG_INFO << "processing results, checking errors/warnings in logs\n"; if (algName.length() == 0) algName = Utils::getLastItemInPath(dirPaths[i]); pprocessor->setBatchDirectoryPath(dirPaths[i] + "/"); pprocessor->setBatchName(algName); checkErrorsProcess(logPaths , dirLogger); pprocessor->calculateBatchResults(); oneclickLogger << FileLogger::LOG_INFO << "experiment result: " << pprocessor->getLastScore().valToString() << "\n"; *dirLogger << FileLogger::LOG_INFO << "experiment result: " << pprocessor->getLastScore().valToString() << "\n"; oneclickLogger << FileLogger::LOG_INFO << "experiment processed\n\n"; *dirLogger << FileLogger::LOG_INFO << "experiment processed\n\n"; } else { oneclickLogger << FileLogger::LOG_WARNING << "experiment won't be processed. Remove invalid runs before processing!\n\n"; *dirLogger << FileLogger::LOG_WARNING << "experiment won't be processed. Remove invalid runs before processing!\n\n"; } configPaths.clear(); logPaths.clear(); algName.clear(); delete dirLogger; } pprocessor->saveResults(); delete pprocessor; oneclickLogger << FileLogger::LOG_INFO << "finished processing results\n"; }
int main() { int n; char nomes[NumNomes][TamMaxNomes] = {"Ricardo", "Joao","Tiago", "Maria", "Joana", "Goncalo", "Rafael", "Teresa"}; sortStrings(nomes); printf("\nOs nomes ordenados sao:\n\n"); for (n = 0; n < NumNomes; n++) printf("%s\n", nomes[n]); return 0; }
void ResultProcessor::getDirectoryPaths(const std::string & directory, std::vector<std::string> & dirPaths) { fs::directory_iterator end; fs::directory_iterator dirIter(directory); if (dirIter == end) throw std::runtime_error("given argument is not a path to existing directory: " + directory); //Saves all paths to directories except . and .. for (; dirIter != end; dirIter++){ if (dirIter.is_directory() && dirIter.name().compare(".") != 0 && dirIter.name().compare("..") != 0) { dirPaths.push_back(dirIter.path()); } } sortStrings(dirPaths); }
int main(int argc, const char *argv[]) { char *strs[5]; char str[5][50]; for(int i = 0; i < 5; ++i){ strs[i] = *(str + i); gets(strs[i]); } printf("\n"); sortStrings(strs); for(int i = 0; i < 5; ++i){ puts(strs[i]); } return 0; }
// You should study and understand how this main function works. // Do not modify it in any way, there is no implementation needed here. void main() { int selection; // used for program selection char input[32]; // used for encryption int encrypt; // used for encryption char strings[5][32]; // used for sorting int num; // used for multiplication table int mt[50][50]; // used for multiplication table printf("Select one of the following:\n"); // prompt for program selection integer printf("1: Encryption\n"); printf("2. Sorting\n"); printf("3. Multiplication Table\n"); scanf("%d", &selection); // store program selection integer getchar(); // consume '\n' char; NOTE: If you are using GCC, you may need to comment out this line printf("\n"); // newline switch (selection) { case 1: printf("Enter a string up to 20 characters long: "); // prompt for string fgets(input, sizeof(input), stdin); // store string input[strlen(input) - 1] = '\0'; // discard '\n' char; NOTE: If you are using GCC, you may need to comment out this line printf("Enter an Integer value for Encryption: "); // prompt for integer scanf("%d", &encrypt); // store integer encryption(input, 2); // encrypt string printf("\nEncrypted String: %s\n", input); // print encrypted string decryption(input, 2); // encrypt string printf("Decrypted String: %s\n", input); // print decrypted string break; case 2: printf("Enter the first String: "); // prompt for string fgets(strings[0], sizeof(strings[0]), stdin); // store string printf("Enter the second String: "); fgets(strings[1], sizeof(strings[1]), stdin); printf("Enter the third String: "); fgets(strings[2], sizeof(strings[2]), stdin); printf("Enter the fourth String: "); fgets(strings[3], sizeof(strings[3]), stdin); printf("Enter the fifth String: "); fgets(strings[4], sizeof(strings[4]), stdin); sortStrings(strings); // call sorting function // print strings in sorted order printf("\nSorted Strings:\n%s%s%s%s%s", strings[0], strings[1], strings[2], strings[3], strings[4]); break; case 3: printf("Enter an integer 1-50 for a multiplication table: "); // prompt for integer scanf("%d", &num); // store integer multiplicationTable(mt, num); // create multiplication table printf("\n"); // newline printMultiplicationTable(mt, num); // print multiplication table } }