void ReadCadmould::param(const char *paramName, bool inMapLoading) { if ((0 == strcmp(paramName, p_filename->getName()) // || 0==strcmp(paramName,p_byteswap->getName()) ) && !inMapLoading) { if (checkFiles(p_filename->getValue())) { openFiles(); if (retOpenFile == -1) // apparently incorrect byte-swapping { byteswap_ = !byteswap_; openFiles(); } } } if (strstr(paramName, "Choice_") && !inMapLoading && retOpenFile == 0) { int number; if (sscanf(paramName, "Choice_%d", &number) != 1) { fprintf(stderr, "ReadCadmould::param: sscanf failed\n"); } // cout << p_choice[number]->getActLabel() <<endl; p_data[number]->setInfo(p_choice[number]->getActLabel()); } }
int main(void){ openFiles(); int i, j, c; scanf("%d %d %d", &N, &P, &C); for (i = 0; i < N; i++){ scanf("%d", &j); cowCount[j]++; } while (C--){ scanf("%d %d %d", &i, &j, &c); addEdge(i,j,c); addEdge(j,i,c); } for (i = 1; i <= P; i++) best = min(best, search(i)); printf("%d\n", best); return 0; }
int main(void) { openFiles(); int i, j, answer = 0; scanf("%d", &N); for (i = 0; i < N; i++) { for (j = 0; j < i; j++) { edges[edgeCount].a = i; edges[edgeCount].b = j; scanf("%d", &edges[edgeCount++].dist); } for (; j < N; j++) scanf("%*d"); } for (i = 0; i < N; i++) setParent[i] = i; qsort(edges, edgeCount, sizeof(edge), edgeCmp); for (i = 0; i < edgeCount; i++) { if (set(edges[i].a) != set(edges[i].b)) { answer += edges[i].dist; join(edges[i].a, edges[i].b); } } printf("%d\n", answer); return 0; }
int ReadN3s::compute(const char *) { // get the file name geofilename = geoFileParam->getValue(); resfilename = resFileParam->getValue(); if (geofilename != NULL || resfilename != NULL) { // open the file if (openFiles()) { sendInfo(infobuf, "Files %s %s open", geofilename, resfilename); // read the file, create the lists and create a COVISE unstructured grid object readGeoFile(); fclose(fpgeo); readResultFile(); fclose(fpres); } else { sendError("Error opening files %s %s", geofilename, resfilename); return STOP_PIPELINE; } } else { sendError("ERROR: fileName for geo or result file is NULL"); } return CONTINUE_PIPELINE; }
int main(void){ openFiles(); int i, j, k; scanf("%d %d %d", &N, &T, &M); for (i = 1; i <= N; i++) scanf("%d", &length[i]); for (i = 1; i <= M; i++){ for (j = 1; j <= N; j++){ for (k = 0; k <= T; k++){ if (k - length[j] >= 0) dp[i][j][k] = max(dp[i][j-1][k], dp[i][j-1][k - length[j]] + 1, dp[i-1][j-1][T] + 1); else dp[i][j][k] = dp[i][j-1][k]; } } } printf("%d\n", dp[M][N][T]); return 0; }
int main(void){ openFiles(); int i, j; int length, neededAnswers, minDifference; scanf("%d %d %d", &neededAnswers, &length, &minDifference); for (i = 0; i < MAXNUM; i++) bitCount[i] = countBits(i); neededAnswers--; // 0 is already an answer for (i = 1; neededAnswers; i++){ int isValid = 1; for (j = 0; j < answerCount; j++){ if (bitCount[i^answers[j]] < minDifference){ isValid = 0; break; } } if (isValid){ answers[answerCount++] = i; neededAnswers--; } } for (i = 0; i < answerCount; i++) printf("%d%s", answers[i], (i+1) % 10 && i != answerCount-1 ? " " : "\n"); return 0; }
int main(void){ openFiles(); int i, greater; scanf("%d %d", &i, &greater); while(i){ int baseCount = 0, base; greater++; for (base = 2; base <= 10; base++){ memset(buf, 0, 500); changeToBase(greater, base, buf); if (isPalindrome(buf)){ baseCount++; if (baseCount == 2){ i--; printf("%d\n", greater); break; } } } } return 0; }
QImage *AcquisitionModule::getNextFrame() { if (m_currentImageIndex >= m_numberOfFiles) { if (m_parseDirectory) { // We have to change directory m_currentDirIndex++; openFiles(); } else { // We reached the end of the sequences! std::cout << "CDiskInput::getNextFrame() : End of the sequence reached.\n"; return NULL; } } if (m_parseDirectory && m_currentDirIndex >= m_numberOfDirs) { // We reached the end of the sequences! std::cout << "CDiskInput::getNextFrame() : End of the sequence reached.\n"; return NULL; } int retValue; QImage *tmpImage = NULL; retValue = readImageOnDisk(&tmpImage); if (retValue != 1) { // The image is corrupted, we attempt to read the following one... std::cout << "CDiskInput::getNextFrame() : ERROR : error reading an image, skipping...\n"; return getNextFrame(); } else readTimeStamp(tmpImage); m_currentImageIndex++; m_NumFrame++; return tmpImage; }
PropertiesFile* ApplicationProperties::getUserSettings() { if (userProps == nullptr) openFiles(); return userProps; }
//--------------------------------------------------------------------------- void CADUSplitterDialog::on_genAHRPTDataBtn_clicked() { if(!openFiles(true)) return; closeFiles(); }
/* ------------------------------------------------------------------------- */ int main(int argc, char *argv[]) { board_t board; board_t board_in; board_t board_solved; // XXX - someday download and use argtable project // XXX - no, actually use getopt procCmdLine(argc, argv); // Open the output file openFiles(); // OK LET'S GO ... initBoard(&board); // read in the starting board to be solved readBoard(&board); // print board as read in from file printBoard(fpOut, &board, TRUE, FALSE); findAllSolutions(&board); fclose(fpOut); fclose(fpSoln); return (0); }
int main(int argc, const char **argv) { struct CmdlineInfo cmdline; struct pam * imgPam; /* malloced */ struct pam outimg; unsigned int fileCt; Coord * coords; /* malloced */ FILE * headerFileP; FILE * dataFileP; const char ** names; /* malloced */ unsigned int qfactor; /* In per cent */ pm_proginit(&argc, argv); parseCommandLine(argc, argv, &cmdline); headerFileP = cmdline.header ? pm_openw(cmdline.header) : NULL; dataFileP = cmdline.data ? pm_openw(cmdline.data) : NULL; qfactor = qfactorFromQuality(cmdline.quality, cmdline.quality2); openFiles(cmdline, &fileCt, &imgPam, &names); readFileHeaders(imgPam, fileCt); sortImagesByArea(fileCt, imgPam, names); findpack(imgPam, fileCt, &coords, cmdline.quality2, qfactor); computeOutputType(&outimg.maxval, &outimg.format, outimg.tuple_type, &outimg.depth, fileCt, imgPam); computeOutputDimensions(&outimg.width, &outimg.height, fileCt, imgPam, coords); outimg.size = sizeof(outimg); outimg.len = PAM_STRUCT_SIZE(allocation_depth); pnm_setminallocationdepth(&outimg, outimg.depth); outimg.plainformat = false; outimg.file = stdout; writePam(&outimg, fileCt, coords, imgPam); if (dataFileP) writeData(dataFileP, outimg.width, outimg.height, fileCt, names, coords, imgPam); if (headerFileP) writeHeader(headerFileP, cmdline.prefix, outimg.width, outimg.height, fileCt, names, coords, imgPam); closeFiles(imgPam, fileCt, headerFileP, dataFileP); free(coords); free(imgPam); free(names); return 0; }
void MainWindow::openFile() { QStringList fileNames = QFileDialog::getOpenFileNames(this, tr("Open tasklist(s)..."), QString(), tr("Tasklist (*.json);;Any (*.*)")); openFiles(fileNames); }
void MainWindow::open() { QStringList fileNames = QFileDialog::getOpenFileNames( this, "Open files", _recentDir, "Recordings (*.tsv *.txt);;Annotations (*.btd)"); if (fileNames.isEmpty()) { return; } openFiles(fileNames); }
int main(void){ openFiles(); int N, K; scanf("%d %d", &N, &K); printf("%d\n", (f(N, K) - f(N, K-1) + MOD) % MOD); return 0; }
WelcomeBrowser::WelcomeBrowser(LiteApi::IApplication *app, QObject *parent) : LiteApi::IBrowserEditor(parent), m_liteApp(app), m_extension(new Extension), m_widget(new QWidget) { m_browser = new DocumentBrowser(m_liteApp,this); m_browser->toolBar()->hide(); QVBoxLayout *mainLayout = new QVBoxLayout; mainLayout->setMargin(0); mainLayout->addWidget(m_browser->widget()); QPushButton *newFile = new QPushButton(tr("New")); QPushButton *openFile = new QPushButton(tr("Open")); QPushButton *openFolder = new QPushButton(tr("Open Folder")); QPushButton *options = new QPushButton(tr("Options")); QHBoxLayout *layout = new QHBoxLayout; layout->addWidget(newFile); layout->addWidget(openFile); layout->addWidget(openFolder); layout->addStretch(1); layout->addWidget(options); mainLayout->addLayout(layout); m_widget->setLayout(mainLayout); connect(newFile,SIGNAL(clicked()),m_liteApp->fileManager(),SLOT(newFile())); connect(openFile,SIGNAL(clicked()),m_liteApp->fileManager(),SLOT(openFiles())); connect(openFolder,SIGNAL(clicked()),this,SLOT(openFolder())); connect(options,SIGNAL(clicked()),m_liteApp->optionManager(),SLOT(exec())); connect(m_browser,SIGNAL(requestUrl(QUrl)),this,SLOT(openUrl(QUrl))); connect(m_liteApp->fileManager(),SIGNAL(recentFilesChanged(QString)),this,SLOT(loadData())); connect(m_browser,SIGNAL(linkHovered(QUrl)),this,SLOT(highlightedUrl(QUrl))); QStringList paths; paths << m_liteApp->resourcePath()+"/welcome" << LiteDoc::localePath(m_liteApp->resourcePath()+"/welcome"); m_browser->setSearchPaths(paths); m_extension->addObject("LiteApi.QTextBrowser",m_browser->htmlWidget()->widget()); QString path = LiteDoc::localeFile(m_liteApp->resourcePath()+"/welcome/welcome.html"); QFile file(path); if (file.open(QIODevice::ReadOnly)) { m_templateData = QString::fromUtf8(file.readAll()); file.close(); } loadData(); }
Boolean WISInput::initialize(UsageEnvironment& env) { do { if (!openFiles(env)) break; if (!initALSA(env)) break; if (!initV4L(env)) break; return True; } while (0); // An error occurred return False; }
EntitiesTreeWidget::EntitiesTreeWidget(QWidget *parent) : QTreeWidget(parent) { applicationNode = new QTreeWidgetItem(this,QStringList() << "Application"); modulesNode = new QTreeWidgetItem(this,QStringList() << "Modules"); resourcesNode = new QTreeWidgetItem(this,QStringList() << "Resources"); templatesNode = new QTreeWidgetItem(this,QStringList() << "Templates"); applicationNode->setIcon(0,QIcon(":/images/folderapp_ico.png")); modulesNode->setIcon(0,QIcon(":/images/foldermod_ico.png")); resourcesNode->setIcon(0,QIcon(":/images/folderres_ico.png")); templatesNode->setIcon(0,QIcon(":/images/folder_ico.png")); addTopLevelItem(applicationNode); addTopLevelItem(modulesNode); addTopLevelItem(resourcesNode); addTopLevelItem(templatesNode); setExpandsOnDoubleClick(false); setContextMenuPolicy(Qt::CustomContextMenu); resizeColumnToContents(0); connect(this, SIGNAL(itemDoubleClicked(QTreeWidgetItem*,int)),this,SLOT(onItemDoubleClicked(QTreeWidgetItem*,int))); connect(this,SIGNAL(customContextMenuRequested(QPoint)),this,SLOT(onContext(QPoint))); openFile = new QAction("Open File",this); importFile = new QAction("Import Files...",this); topLevelMenu.addAction(openFile); topLevelMenu.addAction(importFile); loadFiles = new QAction("Load",this); QAction *separator = new QAction(this); separator->setSeparator(true); reopen = new QAction("Reopen",this); remove = new QAction("Remove",this); secondLevelMenu.addAction(loadFiles); secondLevelMenu.addAction(separator); secondLevelMenu.addAction(reopen); secondLevelMenu.addAction(remove); edit = new QAction("Edit",this); leafLevelMenu.addAction(edit); connect(loadFiles,SIGNAL(triggered()),this,SLOT(onLoadFile())); connect(openFile,SIGNAL(triggered()),this,SIGNAL(openFiles())); connect(importFile,SIGNAL(triggered()),this,SIGNAL(importFiles())); connect(edit,SIGNAL(triggered()),this,SLOT(onEdit())); connect(remove,SIGNAL(triggered()),this,SLOT(onRemove())); }
/* void getParams() * Get command-line parameters. */ void getParams(int argc, char** argv) { char* outFile = NULL, *inFile = NULL; int windowLen = 0, minLen = 0, opt5 = 1, opt3 = 1; int verbose = 0; float windowAvg = 0.0f, qualAvg = 0.0f; // parse argv for (int i = 1; i < argc; i++) { if (!strcmp(argv[i], HELP)) usage(); else if (!strcmp(argv[i], FIVEOPT)) opt3 = 0; else if (!strcmp(argv[i], THREEOPT)) opt5 = 0; else if (!strcmp(argv[i], VERBOSE)) verbose = 1; else if (i < argc - 1) { if (!strcmp(argv[i], OUTFILE)) outFile = argv[++i]; else if (!strcmp(argv[i], INFILE)) inFile = argv[++i]; else if (!strcmp(argv[i], WINDOWLEN)) windowLen = getInt(argv[++i]); else if (!strcmp(argv[i], WINDOWAVG)) windowAvg = getFloat(argv[++i]); else if (!strcmp(argv[i], QUALAVG)) qualAvg = getFloat(argv[++i]); else if (!strcmp(argv[i], MINLEN)) minLen = getInt(argv[++i]); else exit(error(argv[i], ERRPARAM)); } else exit(error(argv[i], ERRPARAM)); } if (outFile == NULL || inFile == NULL) usage(); // process file File out, in; int gz = 0; if (!strcmp(inFile + strlen(inFile) - strlen(GZEXT), GZEXT)) gz = 1; openFiles(outFile, &out, inFile, &in, gz); readFile(in, out, windowLen, windowAvg, qualAvg, minLen, opt5, opt3, gz, verbose); if ( (gz && (gzclose(in.gzf) != Z_OK || gzclose(out.gzf) != Z_OK)) || ( ! gz && (fclose(in.f) || fclose(out.f))) ) exit(error("", ERRCLOSE)); }
void project_open(char *f1, char *f2, char *f3) // // Input: f1 = pointer to name of input file // f2 = pointer to name of report file // f3 = pointer to name of binary output file // Output: none // Purpose: opens a new SWMM project. // { initPointers(); setDefaults(); openFiles(f1, f2, f3); }
bool ContextBase::isValidState() { if (!openFiles()) { return false; } if (!cmdArgsValid()) { return false; } if (!determineOutputType()) { return false; } return true; }
void MainWindow::refreshScripts() { QApplication::setOverrideCursor( Qt::WaitCursor ); QStringList filesOpened; int nbFilesOpened = treeWidget->getModel()->rowCount(); for (int i = 0; i < nbFilesOpened; ++i){ QModelIndex index = treeWidget->getModel()->index(0, 0, QModelIndex()); filesOpened << treeWidget->getModel()->path(index); treeWidget->getModel()->removeItem(index); } moduleLoader.refreshDirectories(programLoader); openFiles(filesOpened); QApplication::restoreOverrideCursor(); }
int main(int argc, char** argv) { std::ifstream inputfile (SOURCE_DIR "/input.txt"); std::ofstream outputfile (SOURCE_DIR "/output.txt"); if (openFiles(inputfile,outputfile)) { task1p3(inputfile,outputfile); inputfile.close(); outputfile.close(); } else { std::cout << "fail" << std::endl; } return 0; }
void ITmagesApplet::init() { image = new Plasma::Svg; image->setImagePath("widgets/itmages"); image->setContainsMultipleImages(false); path = "/usr/bin/itmages-dolphin-extension"; // define aplet context menu QAction *openAction = new QAction(this); openAction->setText(tr("Open Image(s)...")); actions.append(openAction); connect(openAction, SIGNAL(triggered()), this, SLOT(openFiles())); }
int main() /*********/ { char *cmd; void (*parse_object)( void ); #if defined( _M_I86SM ) || defined( _M_I86MM ) _heapgrow(); /* grow the near heap */ #endif if( !MsgInit() ) return( EXIT_FAILURE ); cmd = AllocMem( CMD_LINE_SIZE ); getcmd( cmd ); InitOutput(); initOptions(); parseOptions( cmd ); openFiles(); InitObj(); parse_object = InitORL() ? ParseObjectORL : ParseObjectOMF; for( ;; ) { InitTables(); ModNameORL = rootName; parse_object(); if( Mod == NULL ) { break; } if( srcReqd ) { if( SrcName == NULL ) { if( CommentName != NULL ) { SrcName = CommentName; } else if( Mod->name != NULL ) { SrcName = Mod->name; } else { SrcName = rootName; } } OpenSource(); } DisAssemble(); if( Source != NULL ) { CloseTxt( Source ); } SrcName = NULL; /* if another module, get name from obj file */ } if( UseORL ) FiniORL(); CloseBin( ObjFile ); CloseTxt( Output ); MsgFini(); return( 0 ); }
void SamaelMainWindow::createActions() { // "Open" Action m_OpenAction = new QAction(tr("&Open File(s)"), this); m_OpenAction->setShortcut(Qt::CTRL + Qt::Key_O); m_OpenAction->setToolTip(tr("Open File(s)")); m_OpenAction->setStatusTip(tr("Open File(s)")); connect(m_OpenAction, SIGNAL(triggered()), m_TreeWidget, SLOT(openFiles())); // "Open Folder" Action m_OpenFolderAction = new QAction(tr("Open &Folder (Recursive)"), this); m_OpenFolderAction->setShortcut(Qt::CTRL + Qt::Key_F); m_OpenFolderAction->setToolTip(tr("Open Folder (Recursive)")); m_OpenFolderAction->setStatusTip(tr("Open Folder (Recursive)")); connect(m_OpenFolderAction, SIGNAL(triggered()), m_TreeWidget, SLOT(openDirectory())); // "Open Confusion Matrix" Action m_OpenConfusionMatrixAction = new QAction(tr("Open Confusion &Matrix"), this); m_OpenConfusionMatrixAction->setShortcut(Qt::CTRL + Qt::Key_M); m_OpenConfusionMatrixAction->setToolTip(tr("Open Confusion Matrix")); m_OpenConfusionMatrixAction->setStatusTip(tr("Open Confusion Matrix")); connect(m_OpenConfusionMatrixAction, SIGNAL(triggered()), m_CentralWidget->getDataViewerWidget(), SLOT(loadConfusionMatrices())); // "Save Confusion Matrix" Action m_SaveConfusionMatrixAction = new QAction(tr("Save Confusion &Matrix"), this); m_SaveConfusionMatrixAction->setShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_M); m_SaveConfusionMatrixAction->setToolTip(tr("Save Confusion Matrix")); m_SaveConfusionMatrixAction->setStatusTip(tr("Save Confusion Matrix")); connect(m_SaveConfusionMatrixAction, SIGNAL(triggered()), m_CentralWidget->getDataViewerWidget(), SLOT(saveConfusionMatrices())); // "Exit" Action m_ExitAction = new QAction(tr("&Exit"), this); m_ExitAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Q)); m_ExitAction->setToolTip(tr("Exit Application")); m_ExitAction->setStatusTip(tr("Exit Application")); connect(m_ExitAction, SIGNAL(triggered()), this, SLOT(exit())); // "About" Action m_AboutAction = new QAction(tr("&About"), this); m_AboutAction->setToolTip(tr("About Application")); m_AboutAction->setStatusTip(tr("About Application")); connect(m_AboutAction, SIGNAL(triggered()), this, SLOT(about())); // "Toggle Main View" Action m_ToggleMainViewAction = new QAction(tr("Toggle Main View"), this); m_ToggleMainViewAction->setShortcut(Qt::CTRL + Qt::Key_Space); m_ToggleMainViewAction->setToolTip(tr("Toggle Main View")); m_ToggleMainViewAction->setStatusTip(tr("Toggle Main View")); connect(m_ToggleMainViewAction, SIGNAL(triggered()), m_CentralWidget, SLOT(toggleWidget())); }
int main(void){ openFiles(); int i; for (i = 0; i < CLOCKNUM; i++){ scanf("%hd", &start.clocks[i]); start.clocks[i] /= 3; // scale the statuses start.clocks[i] %= STATENUM; } reconstruct(search(), 1); return 0; }
bool ContextBase::isValidState() { if (!openFiles()) { return false; } if (!cmdArgsValid()) { return false; } if (!determineOutputType()) { return false; } if (_program != GROUP_BY && _files[0]->getRecordType() == FileRecordTypeChecker::NO_POS_PLUS_RECORD_TYPE) { _errorMsg = "ERROR: file "; _errorMsg.append(_files[0]->getFileName()); _errorMsg.append(" has non positional records, which are only valid for \n"); _errorMsg.append(" the groupBy tool. Perhaps you are using a header"); _errorMsg.append(" line(s) that starts with \n"); _errorMsg.append(" something other than \"#\", \"chrom\", or \"chr\" (any case)?"); return false; } if (getObeySplits()) { _splitBlockInfo = new BlockMgr(_overlapFractionA, _reciprocalFraction); } if (hasColumnOpsMethods()) { if (hasIntersectMethods()) { for (int i=0; i < (int)_dbFileIdxs.size(); i++) { FileRecordMgr *dbFile = getFile(_dbFileIdxs[i]); _keyListOps->setDBfileType(dbFile->getFileType()); if (!_keyListOps->isValidColumnOps(dbFile)) { return false; } } } else { FileRecordMgr *dbFile = getFile(0); _keyListOps->setDBfileType(dbFile->getFileType()); if (!_keyListOps->isValidColumnOps(dbFile)) { return false; } } //if user specified a precision, pass it to //keyList ops if (_reportPrecision != -1) { _keyListOps->setPrecision(_reportPrecision); } } return true; }
void MdCharmApplication::newConnectionSlot() { qDebug( "new connection" ); QLocalSocket *socket = localServer->nextPendingConnection(); if ( !socket ) { return; } socket->waitForReadyRead( 1000 ); QTextStream stream( socket ); QString args = stream.readAll(); delete socket; emit openFiles( args.split( "," ) ); }
int main(void){ openFiles(); int i; scanf("%d", &size); if (size < 13) backtrack(1); else trickyTrick(); printf("%d\n", answer); return 0; }