void sort(int bl[],int x){ int tmp;//一時 int cmp=0,swp=0;//比較、交換 int i, j;//ループ用 for(i=0;i<x;i++){//x=20 for(j=0;j<(x-1)-i;j++){ SetDrawScreen(DX_SCREEN_BACK); // 描画先を裏画面へ ClsDrawScreen(); //裏画面消去 cmp++;//比較+1 if(bl[j]>bl[j+1]){ swp++;//交換+1 tmp =bl[j]; bl[j]=bl[j+1]; bl[j+1]=tmp; } showHeader(cmp, swp);//ヘッダー表示 showGraph(bl, ARRAY_SIZE, j);//表示 //_sleep(10); ScreenFlip(); // 裏画面を表画面へ } } /////////////////////////////////////////////// }
void Stack::setMargins(int footer, int header) { m_footer_margin = footer; m_header_margin = header; m_footer_visible = (m_footer_visible != 0) ? -m_footer_margin : 0; m_header_visible = (m_header_visible != 0) ? m_header_margin : 0; updateMask(); showHeader(); }
void ScribusQApp::showError(QString arg) { showHeader(); if (arg.left(1) == "-" || arg.left(2) == "--") { std::cout << tr("Invalid argument: %1").arg(arg).toLocal8Bit().data() << std::endl; } else { std::cout << tr("File %1 does not exist, aborting.").arg(arg).toLocal8Bit().data() << std::endl; } showUsage(); std::cout << tr("Scribus Version").toLocal8Bit().data() << " " << VERSION << std::endl; }
int createMenu(STR menu[]) { system("cls"); showHeader(); int choice; for (int i = 0; menu[i] != NULL; i++) printf("%s\n", menu[i]); printf(" > "); scanf("%d", &choice); return choice; }
STR createInput(STR text) { system("cls"); showHeader(); char *str = new char[MAX_STR]; printf("%s\n", text); flushall(); printf(" > "); gets(str); return str; }
int createBox(STR text, int style, bool cont) { if (!cont) { system("cls"); showHeader(); } while (1) { printf("%s ", text); if (style == 1) printf("[o] > "); else if (style == 2) printf("[y/n] > "); flushall(); char bx = getchar(); if (bx == 'o' && style == 1) return BX_OK; else if (bx == 'y' && style == 2) return BX_YES; else if (bx == 'n' && style == 2) return BX_NO; } }
void sort(int bl[],int x){ int tmp;//一時 int cmp=0,swp=0;//比較、交換 int i, j;//ループ用 //比較/////////////////////////////////// for(i=0;i<x;i++){ for(j=0;j<x-1-i;j++){ cmp++;//比較+1 clear(); showHeader(cmp, swp); showGraph(bl, ARRAY_SIZE, j); if(bl[j]>bl[j+1]){ swp++;//交換+1 tmp =bl[j]; bl[j]=bl[j+1]; bl[j+1]=tmp; } //Sleep(100); } } /////////////////////////////////////////////// }
int main(){ setlocale(LC_ALL, "ptb");//Set pt-br locale initscr();//Initialize cursor mode start_color();//Initialize color mode getmaxyx(stdscr,row,col);//Get screen dimensions attron(A_BOLD); //Configure color pairs init_pair(1, COLOR_WHITE, COLOR_BLACK);//Our default init_pair(2, COLOR_BLUE, COLOR_BLACK);//For Player 1 init_pair(3, COLOR_RED, COLOR_BLACK);//For Player 2 //Set default color pair wbkgd(stdscr, COLOR_PAIR(1)); //Refresh screen to apply refresh(); //Splash screen splashScreen(); //wclear(stdscr); //Ready! char playAgain = 's';//Answer to the play again question on the end //Restart the game while play again answer is positive while(playAgain == 's'){ initializeGameTable();//Initialize game table showHeader();//Show header with only title requestPlayerNames();//Request players for typing their names showHeader();//Show header with the title and players names refreshGame();//Show the game table //Print a divisor line after a blank line printw("\n"); for(short int i = 0; i < col; i++){ printw("-"); } /* Here is the game, we'll request a match and refresh the game table while the game is not won or tied (tied is defined by number of matches) */ //Matches counter int matchesCounter = 1; //Disable cursor curs_set(0); //While the game is not won and matches counter is under/equal 9 while(checkWin() == 0 && matchesCounter <= 9){ //Request match requestMatch(); //Refresh the game table refreshGame(); //Increase matches counter matchesCounter++; } //Clear line 13 move(13,0); clrtoeol(); //Check who won, or if the game tied if(checkWin() == 1){ //Player 1 won //Increase score player1Score++; //Show congratulations on player color attron(COLOR_PAIR(2)); mvprintw(13, 0, "Parabéns %s, você ganhou!\n", player1); attron(COLOR_PAIR(1)); } if(checkWin() == 2){ if(!strcmp(player2, "")){ //PC won //Increase score player2Score++; //Show congratulations on player color attron(COLOR_PAIR(3)); mvprintw(13, 0, "O PC ganhou!\n", player2); attron(COLOR_PAIR(1)); }else{ //Player2 won //Increase score player2Score++; //Show congratulations on player color attron(COLOR_PAIR(3)); mvprintw(13, 0, "Parabéns %s, você ganhou!\n", player2); attron(COLOR_PAIR(1)); } } if(checkWin() == 0){ //Game tied mvprintw(13, 0, "Deu velha! O jogo terminou em empate.\n"); } //Refresh scores refreshScores(); //Reset play again var playAgain = ' '; //Enable cursor curs_set(1); //Validate play again answer while(!(playAgain == 's' | playAgain == 'n')){ //Clear line 15, removing possible wrong answers from screen move(15, 0); clrtoeol(); //Ask user printw("Desejam jogar novamente?[s/n] "); playAgain = getch(); } } //Disable cursor curs_set(0); //Clear screen and show the header showHeader(); //Print the thanks on center mvprintw(6, (col-strlen("Obrigado por jogar!"))/2,"Obrigado por jogar!\n"); //Delay refresh(); delay(600); //Print the credits mvprintw(9, 0, "Desenvolvido por:\n"); printw("Renan Galeno <*****@*****.**>\n"); printw("Marcos Antuanny <*****@*****.**>\n"); printw("Victor Patrick <*****@*****.**>\n"); printw("\n"); //Delay refresh(); delay(600); printw("Este trabalho está licenciado sob uma Licença Creative Commons Atribuição-CompartilhaIgual 4.0 Internacional.\nPara ver uma cópia desta licença, visite http://creativecommons.org/licenses/by-sa/4.0/.\n\n"); //Delay refresh(); delay(1000); //Print the press anything to exit message printw("Pressione qualquer tecla para sair."); getch(); //End curses mode endwin(); //Return 0, as the program had no errors return(0); }
void ScribusQApp::parseCommandLine() { showSplash=!neverSplashExists(); QString arg(""); bool usage=false; bool header=false; bool availlangs=false; bool version=false; bool runUpgradeCheck=false; showFontInfo=false; showProfileInfo=false; swapDialogButtonOrder=false; //Parse for command line information options, and lang for(int i = 1; i < argc(); i++) { arg = argv()[i]; if ((arg == ARG_LANG || arg == ARG_LANG_SHORT) && (++i < argc())) { lang = argv()[i]; } else if (arg == ARG_VERSION || arg == ARG_VERSION_SHORT) { header=true; version=true; } else if (arg == ARG_HELP || arg == ARG_HELP_SHORT) { header=true; usage=true; } else if (arg == ARG_AVAILLANG || arg == ARG_AVAILLANG_SHORT) { header=true; availlangs=true; } else if (arg == ARG_UPGRADECHECK || arg == ARG_UPGRADECHECK_SHORT) { header=true; runUpgradeCheck=true; } } //Init translations initLang(); //Show command line help if (header) showHeader(); if (version) showVersion(); if (availlangs) showAvailLangs(); if (usage) showUsage(); if (runUpgradeCheck) { UpgradeChecker uc; uc.fetch(); } //Dont run the GUI init process called from main.cpp, and return if (!header) useGUI=true; else return; //We are going to run something other than command line help for(int i = 1; i < argc(); i++) { arg = argv()[i]; if ((arg == ARG_LANG || arg == ARG_LANG_SHORT) && (++i < argc())) { continue; } else if ( arg == ARG_CONSOLE || arg == ARG_CONSOLE_SHORT ) { continue; } else if (arg == ARG_NOSPLASH || arg == ARG_NOSPLASH_SHORT) { showSplash = false; } else if (arg == ARG_NEVERSPLASH || arg == ARG_NEVERSPLASH_SHORT) { showSplash = false; neverSplash(true); } else if (arg == ARG_NOGUI || arg == ARG_NOGUI_SHORT) { useGUI=false; } else if (arg == ARG_FONTINFO || arg == ARG_FONTINFO_SHORT) { showFontInfo=true; } else if (arg == ARG_PROFILEINFO || arg == ARG_PROFILEINFO_SHORT) { showProfileInfo=true; } else if (arg == ARG_SWAPDIABUTTONS || arg == ARG_SWAPDIABUTTONS_SHORT) { swapDialogButtonOrder=true; } else if ((arg == ARG_DISPLAY || arg==ARG_DISPLAY_SHORT || arg==ARG_DISPLAY_QT) && ++i < argc()) { // allow setting of display, QT expect the option -display <display_name> so we discard the // last argument. FIXME: Qt only understands -display not --display and -d , we need to work // around this. } else if (arg == ARG_PREFS || arg == ARG_PREFS_SHORT) { prefsUserFile = QFile::decodeName(argv()[i + 1]); if (!QFileInfo(prefsUserFile).exists()) { showHeader(); if (fileName.left(1) == "-" || fileName.left(2) == "--") { std::cout << tr("Invalid argument: ").toLocal8Bit().data() << fileName.toLocal8Bit().data() << std::endl; } else { std::cout << tr("File %1 does not exist, aborting.").arg(fileName).toLocal8Bit().data() << std::endl; } showUsage(); useGUI=false; return; } else { ++i; } } else if (strncmp(arg.toLocal8Bit().data(),"-psn_",4) == 0) { // Andreas Vox: Qt/Mac has -psn_blah flags that must be accepted. } else { fileName = QFile::decodeName(argv()[i]); if (!QFileInfo(fileName).exists()) { showHeader(); if (fileName.left(1) == "-" || fileName.left(2) == "--") { std::cout << tr("Invalid argument: %1").arg(fileName).toLocal8Bit().data() << std::endl; } else { std::cout << tr("File %1 does not exist, aborting.").arg(fileName).toLocal8Bit().data() << std::endl; } showUsage(); useGUI=false; return; } else { filesToLoad.append(fileName); } } } }
int main(int argc, char** argv) { Recognition* recognition = new Recognition(); if (argc < 2) { showHeader(); return 0; } else if (!strcmp(argv[1], "train")) { recognition->initialize(RECOGNITION_THRESHOLD, USE_MAHALANOBIS_DISTANCE ? MAHALANOBIS_DISTANCE : EUCLIDIAN_DISTANCE, (char*)IMAGE_FILE_EXTENSION, (char*)TRAINING_DATA_FILE); if (argc == 2) { //use default settings int res = recognition->train(USE_DATABASE_FOR_TRAINING ? DATABASE_SRC : FILE_SRC, (char*)TRAINING_SRC_PATH, SAVE_TRAINING_DATA); if (res != 0) { delete recognition; return (EXIT_FAILURE); } recognition->saveTrainingData((char*)TRAINING_DATA_FILE); } else if (argc == 4) { bool useDatabase = true; if (!strcmp(argv[2], "database")) { useDatabase = true; } else if (!strcmp(argv[2], "file")) { useDatabase = false; } else { fprintf(stderr, "Invalid arguments!\n"); showHeader(); delete recognition; return (EXIT_FAILURE); } int res = recognition->train(useDatabase, argv[3], SAVE_TRAINING_DATA); if (res != 0) { delete recognition; return (EXIT_FAILURE); } recognition->saveTrainingData((char*)TRAINING_DATA_FILE); } else { //wrong fprintf(stderr, "Invalid arguments!\n"); showHeader(); delete recognition; return (EXIT_FAILURE); } } else if (!strcmp(argv[1], "test")) { if (argc == 2) { //use default settings recognition->initialize(RECOGNITION_THRESHOLD, USE_MAHALANOBIS_DISTANCE ? MAHALANOBIS_DISTANCE : EUCLIDIAN_DISTANCE, (char*)IMAGE_FILE_EXTENSION, (char*)TRAINING_DATA_FILE); if (recognition->loadTrainingData((char*)TRAINING_DATA_FILE) != 0) { fprintf(stderr, "Run training first! \n"); delete recognition; return (EXIT_FAILURE); } recognition->testRecognitionPerformance((char*)TEST_FILE_PATH); } else if (argc == 4) { char* filePath = argv[2]; float threshold = atof(argv[3]); recognition->initialize(threshold, USE_MAHALANOBIS_DISTANCE ? MAHALANOBIS_DISTANCE : EUCLIDIAN_DISTANCE, (char*)IMAGE_FILE_EXTENSION, (char*)TRAINING_DATA_FILE); if (recognition->loadTrainingData((char*)TRAINING_DATA_FILE) != 0) { fprintf(stderr, "Run training first! \n"); delete recognition; return (EXIT_FAILURE); } recognition->testRecognitionPerformance((char*)filePath); } else { //wrong fprintf(stderr, "Invalid arguments!\n"); showHeader(); delete recognition; return (EXIT_FAILURE); } } delete recognition; return (EXIT_SUCCESS); }
void ScribusQApp::parseCommandLine() { m_showSplash=!neverSplashExists(); QString arg(""); bool usage=false; bool header=false; bool availlangs=false; bool version=false; bool runUpgradeCheck=false; #ifdef WITH_TESTS bool runtests = false; char** testargsv; int testargsc; #endif m_showFontInfo=false; m_showProfileInfo=false; bool neversplash = false; //Parse for command line options // Qt5 port: do this in a Qt compatible manner QStringList args = arguments(); int argsc = args.count(); useGUI = true; int argi = 1; for( ; argi < argsc; argi++) { //handle options (not positional parameters) arg = args[argi]; if (arg == ARG_PYTHONSCRIPT || arg == ARG_PYTHONSCRIPT_SHORT) { if (argi+1 == argsc) { std::cout << tr("Option %1 requires an argument.").arg(arg).toLocal8Bit().data() << std::endl; std::exit(EXIT_FAILURE); } pythonScript = QFile::decodeName(args[argi + 1].toLocal8Bit()); if (!QFileInfo(pythonScript).exists()) { std::cout << tr("Python script %1 does not exist, aborting.").arg(pythonScript).toLocal8Bit().data() << std::endl; std::exit(EXIT_FAILURE); } ++argi; while (++argi < argsc && (args[argi] != CMD_OPTIONS_END)) { pythonScriptArgs.append(args[argi]); // script argument } // We reached end of all arguments or CMD_OPTIONS_END marker. Stop parsing options if (argi < argsc) { argi++; // skip CMD_OPTIONS_END } break; } else if ((arg == ARG_LANG || arg == ARG_LANG_SHORT)) { if (++argi < argsc) m_lang = args[argi]; else { std::cout << tr("Option %1 requires an argument.").arg(arg).toLocal8Bit().data() << std::endl; std::exit(EXIT_FAILURE); } } else if (arg == ARG_VERSION || arg == ARG_VERSION_SHORT) { header=true; version=true; } else if (arg == ARG_HELP || arg == ARG_HELP_SHORT) { header=true; usage=true; } #ifdef WITH_TESTS else if (arg == ARG_TESTS || arg == ARG_TESTS_SHORT) { header=true; runtests=true; testargsc = argc() - argi; testargsv = argv() + argi; break; } #endif else if (arg == ARG_AVAILLANG || arg == ARG_AVAILLANG_SHORT) { header=true; availlangs=true; } else if (arg == ARG_UPGRADECHECK || arg == ARG_UPGRADECHECK_SHORT) { header=true; runUpgradeCheck=true; } else if ( arg == ARG_CONSOLE || arg == ARG_CONSOLE_SHORT ) { continue; } else if (arg == ARG_NOSPLASH || arg == ARG_NOSPLASH_SHORT) { m_showSplash = false; } else if (arg == ARG_NEVERSPLASH || arg == ARG_NEVERSPLASH_SHORT) { m_showSplash = false; neversplash = true; } else if (arg == ARG_NOGUI || arg == ARG_NOGUI_SHORT) { useGUI=false; } else if (arg == ARG_FONTINFO || arg == ARG_FONTINFO_SHORT) { m_showFontInfo=true; } else if (arg == ARG_PROFILEINFO || arg == ARG_PROFILEINFO_SHORT) { m_showProfileInfo=true; } else if ((arg == ARG_DISPLAY || arg==ARG_DISPLAY_SHORT || arg==ARG_DISPLAY_QT) && ++argi < argsc) { // allow setting of display, QT expect the option -display <display_name> so we discard the // last argument. FIXME: Qt only understands -display not --display and -d , we need to work // around this. } else if (arg == ARG_PREFS || arg == ARG_PREFS_SHORT) { if (argi+1 == argsc) { std::cout << tr("Option %1 requires an argument.").arg(arg).toLocal8Bit().data() << std::endl; std::exit(EXIT_FAILURE); } m_prefsUserFile = QFile::decodeName(args[argi + 1].toLocal8Bit()); if (!QFileInfo(m_prefsUserFile).exists()) { std::cout << tr("Preferences file %1 does not exist, aborting.").arg(m_prefsUserFile).toLocal8Bit().data() << std::endl; std::exit(EXIT_FAILURE); } else { ++argi; } } else if (strncmp(arg.toLocal8Bit().data(),"-psn_",4) == 0) { // Andreas Vox: Qt/Mac has -psn_blah flags that must be accepted. } else if (arg == CMD_OPTIONS_END) { //double dash, indicates end of command line options, see http://unix.stackexchange.com/questions/11376/what-does-double-dash-mean-also-known-as-bare-double-dash argi++; break; } else { //argument is not a known option, but either positional parameter or invalid. if (arg.left(1) == "-") { std::cout << tr("Invalid argument: %1").arg(arg).toLocal8Bit().data() << std::endl; std::exit(EXIT_FAILURE); } m_fileName = QFile::decodeName(args[argi].toLocal8Bit()); if (!QFileInfo(m_fileName).exists()) { std::cout << tr("File %1 does not exist, aborting.").arg(m_fileName).toLocal8Bit().data() << std::endl; std::exit(EXIT_FAILURE); } else { m_filesToLoad.append(m_fileName); } } } // parse for remaining (positional) arguments, if any for ( ; argi<argsc; argi++) { m_fileName = QFile::decodeName(args[argi].toLocal8Bit()); if (!QFileInfo(m_fileName).exists()) { std::cout << tr("File %1 does not exist, aborting.").arg(m_fileName).toLocal8Bit().data() << std::endl; std::exit(EXIT_FAILURE); } else { m_filesToLoad.append(m_fileName); } } //Init translations initLang(); //Show command line info if (header) { useGUI = false; showHeader(); } if (version) showVersion(); if (availlangs) showAvailLangs(); if (usage) showUsage(); #ifdef WITH_TESTS if (runtests) RunTests::runTests(testargsc, testargsv); #endif if (runUpgradeCheck) { UpgradeChecker uc; uc.fetch(); } //Don't run the GUI init process called from main.cpp, and return if (header) std::exit(EXIT_SUCCESS); //proceed if(neversplash) neverSplash(true); }
void ScribusQApp::parseCommandLine() { showSplash=!neverSplashExists(); QString arg(""); bool usage=false; bool header=false; bool availlangs=false; bool version=false; bool runUpgradeCheck=false; #ifdef WITH_TESTS bool runtests = false; char** testargsv; int testargsc; #endif showFontInfo=false; showProfileInfo=false; //Parse for command line information options, and lang // Qt5 port: do this in a Qt compatible manner QStringList args = arguments(); int argsc = args.count(); for(int i = 1; i < argsc; i++) { arg = args[i]; if ((arg == ARG_LANG || arg == ARG_LANG_SHORT) && (++i < argsc)) { lang = args[i]; } else if (arg == ARG_VERSION || arg == ARG_VERSION_SHORT) { header=true; version=true; } else if (arg == ARG_HELP || arg == ARG_HELP_SHORT) { header=true; usage=true; } #ifdef WITH_TESTS else if (arg == ARG_TESTS || arg == ARG_TESTS_SHORT) { header=true; runtests=true; testargsc = argc() - i; testargsv = argv() + i; break; } #endif else if (arg == ARG_AVAILLANG || arg == ARG_AVAILLANG_SHORT) { header=true; availlangs=true; } else if (arg == ARG_UPGRADECHECK || arg == ARG_UPGRADECHECK_SHORT) { header=true; runUpgradeCheck=true; } } //Init translations initLang(); //Show command line help if (header) showHeader(); if (version) showVersion(); if (availlangs) showAvailLangs(); if (usage) showUsage(); #ifdef WITH_TESTS if (runtests) RunTests::runTests(testargsc, testargsv); #endif if (runUpgradeCheck) { UpgradeChecker uc; uc.fetch(); } //Dont run the GUI init process called from main.cpp, and return if (header) std::exit(EXIT_SUCCESS); useGUI = true; //We are going to run something other than command line help for(int i = 1; i < argsc; i++) { arg = args[i]; if ((arg == ARG_LANG || arg == ARG_LANG_SHORT) && (++i < argsc)) { continue; } else if ( arg == ARG_CONSOLE || arg == ARG_CONSOLE_SHORT ) { continue; } else if (arg == ARG_NOSPLASH || arg == ARG_NOSPLASH_SHORT) { showSplash = false; } else if (arg == ARG_NEVERSPLASH || arg == ARG_NEVERSPLASH_SHORT) { showSplash = false; neverSplash(true); } else if (arg == ARG_NOGUI || arg == ARG_NOGUI_SHORT) { useGUI=false; } else if (arg == ARG_FONTINFO || arg == ARG_FONTINFO_SHORT) { showFontInfo=true; } else if (arg == ARG_PROFILEINFO || arg == ARG_PROFILEINFO_SHORT) { showProfileInfo=true; } else if ((arg == ARG_DISPLAY || arg==ARG_DISPLAY_SHORT || arg==ARG_DISPLAY_QT) && ++i < argsc) { // allow setting of display, QT expect the option -display <display_name> so we discard the // last argument. FIXME: Qt only understands -display not --display and -d , we need to work // around this. } else if (arg == ARG_PREFS || arg == ARG_PREFS_SHORT) { prefsUserFile = QFile::decodeName(args[i + 1].toLocal8Bit()); if (!QFileInfo(prefsUserFile).exists()) { showHeader(); if (prefsUserFile.left(1) == "-" || prefsUserFile.left(2) == "--") { std::cout << tr("Invalid argument: ").toLocal8Bit().data() << prefsUserFile.toLocal8Bit().data() << std::endl; } else { std::cout << tr("File %1 does not exist, aborting.").arg(prefsUserFile).toLocal8Bit().data() << std::endl; } showUsage(); std::exit(EXIT_FAILURE); } else { ++i; } } else if (strncmp(arg.toLocal8Bit().data(),"-psn_",4) == 0) { // Andreas Vox: Qt/Mac has -psn_blah flags that must be accepted. } else if (arg == ARG_PYTHONSCRIPT || arg == ARG_PYTHONSCRIPT_SHORT) { pythonScript = QFile::decodeName(args[i + 1].toLocal8Bit()); if (!QFileInfo(pythonScript).exists()) { showHeader(); if (pythonScript.left(1) == "-" || pythonScript.left(2) == "--") { std::cout << tr("Invalid argument: ").toLocal8Bit().data() << pythonScript.toLocal8Bit().data() << std::endl; } else { std::cout << tr("File %1 does not exist, aborting.").arg(pythonScript).toLocal8Bit().data() << std::endl; } showUsage(); std::exit(EXIT_FAILURE); } else { ++i; } } else { fileName = QFile::decodeName(args[i].toLocal8Bit()); if (!QFileInfo(fileName).exists()) { showHeader(); if (fileName.left(1) == "-" || fileName.left(2) == "--") { std::cout << tr("Invalid argument: %1").arg(fileName).toLocal8Bit().data() << std::endl; } else { std::cout << tr("File %1 does not exist, aborting.").arg(fileName).toLocal8Bit().data() << std::endl; } showUsage(); std::exit(EXIT_FAILURE); } else { filesToLoad.append(fileName); } } } }