Ejemplo n.º 1
1
// Recursively walks down an ownership tree of AsdkOwnerDemo
// class objects, printing out information on each one.
//
void
printOut(AcDbObjectId id)
{
    AsdkOwnerDemo *pDemo;
    acdbOpenObject((AcDbObject*&)pDemo, id, AcDb::kForRead);
    acutPrintf("\nIntdata: %d  ObjId: %ld  Backpointer:"
               " %ld OwnedObj: %ld", pDemo->intData(),
               (pDemo->objectId()).asOldId(),
               (pDemo->ownerId()).asOldId(),
               (pDemo->idData()).asOldId());

    // Recursive tree walk
    //
    if ((pDemo->idData()).asOldId() != 0L) {
        printOut(pDemo->idData());
    }
    pDemo->close();
}
Ejemplo n.º 2
0
// Recursively traverse an eZ Publish directory
static void traverse( const QDir &dir, Translator &fetchedTor, ConversionData cd, UpdateOptions options, bool *fail )
{
    if ( options & Verbose )
        printOut( QObject::tr( "   Checking subdirectory '%1'" ).arg( qPrintable(dir.path()) ) );

    if ( !dir.exists() )
        return;

    const QFileInfoList list = dir.entryInfoList();
    QFileInfo fi;
    for ( int i = 0; i < list.size(); ++i )
    {
        fi = list.at( i );
        if ( fi.fileName().startsWith( "." ) )
        {
            // Do nothing
        }
        else if ( fi.isDir() )
        {
            QDir subdir = dir;
            subdir.setCurrent( subdir.path() + QDir::separator() + fi.fileName() );
            traverse( subdir.currentPath(), fetchedTor, cd, options, fail );
            subdir.setCurrent( dir.path() );
        }
        else
        {
            if ( fi.fileName().endsWith(QLatin1String(".php"), Qt::CaseInsensitive) )
            {
                if ( options & Verbose )
                    printOut( QObject::tr( "      Checking '%1'" ).arg( qPrintable(fi.fileName()) ) );
                if ( !fetchedTor.load(fi.fileName(), cd, QLatin1String("php")) )
                {
                    qWarning( "%s", qPrintable( cd.error() ) );
                    *fail = true;
                }
            }
            else if ( fi.fileName().endsWith(QLatin1String(".tpl"), Qt::CaseInsensitive) )
            {
                if ( options & Verbose )
                    printOut( QObject::tr( "      Checking '%1'" ).arg( qPrintable(fi.fileName()) ) );
                if ( !fetchedTor.load(fi.fileName(), cd, QLatin1String("tpl")) )
                {
                    qWarning( "%s", qPrintable( cd.error() ) );
                    *fail = true;
                }
            }
        }
    }
}
Ejemplo n.º 3
0
int main(void)
{
    /* Sets are predefined per requirements */
    int set_1[] = { 5, 1, 3 };
    int size_1 = sizeof(set_1) / sizeof(set_1[0]);
    int set_2[] = { 8, 5, -1, 3, 2 };
    int size_2 = sizeof(set_2) / sizeof(set_2[0]);
    int set_3[] = { 5, 4, 3, 2, 1 };
    int size_3 = sizeof(set_3) / sizeof(set_3[0]);
    int set_4[] = { 9 };
    int size_4 = sizeof(set_4) / sizeof(set_4[0]);

    printOut(set_1, size_1, set_2, size_2);
    printOut(set_3, size_3, set_4, size_4);
}
Ejemplo n.º 4
0
NdbOut& operator<<(NdbOut& no, const PrepareOperationRecord& por) {
  no << "-----------PREPARE OPERATION RECORD------------" << endl << endl;
  printOut("Record type:", por.m_recordType);
  printOut("logRecordSize:", por.m_logRecordSize);
  printOut("hashValue:", por.m_hashValue);
  switch (por.m_operationType) {
  case 0:
    ndbout_c("%-30s%-12u%-6s", "operationType:", 
	     por.m_operationType, "read");
    break;
  case 1:
    ndbout_c("%-30s%-12u%-6s", "operationType:", 
	     por.m_operationType, "update");
    break;
  case 2:
    ndbout_c("%-30s%-12u%-6s", "operationType:", 
	     por.m_operationType, "insert");
    break;
  case 3:
    ndbout_c("%-30s%-12u%-6s", "operationType:", 
	     por.m_operationType, "delete");
    break;
  default:
    printOut("operationType:", por.m_operationType);
  }
  printOut("page_no: ", por.m_page_no);
  printOut("page_idx: ", por.m_page_idx);
  printOut("attributeLength:", por.m_attributeLength);
  printOut("keyLength:", por.m_keyLength);

#if 1
  // Print keydata
  Uint32* p = (Uint32*)&por.m_keyInfo;
  for(Uint32 i=0; i < por.m_keyLength; i++){    
    printOut("keydata:", *p);
    p++;
  }

  // Print attrdata
  for(Uint32 i=0; i < por.m_attributeLength; i++){    
    printOut("attrdata:", *p);
    p++;
  }
#endif

  no << endl;
  return no;
}
Ejemplo n.º 5
0
// Check if there's any text to work with
bool Transmute::validSize(){
	if (heldText.size() <= 1){
		printOut();
		return false;
	}
	return true;
}
Ejemplo n.º 6
0
Archivo: lab07.c Proyecto: 0lumide/cs
int main()
{
  //LOCAL DECLARATION
  int input; //This is the number entered by the user received from getInput
  int num; //This is the variable to be used in the for loop to find the firt prime number
  int count; //This is the vaue recieved from calcPrime function
  int sec_num; //This is the second number that fulfils the condition of adding to the first number to give double the input
  int count2 = 1; //This counts the amount of pairs of prime numbers that have been found

  //EXECUTABLE STATEMENTS
  input = getInput();
  for (num = 1; num <= input; num++)
  {
    count = calcPrime(num);
    if (count == 2)
    {
      sec_num = input * 2 - num;
      count = calcPrime(sec_num);
      if (count == 2)
      {
        printOut(num, sec_num, & count2);
        count2++;
      }
    }
  }
  if (count2 == 1)
  {
    printf("\nNo prime pairs found.");
  }
  printf("\n\n");
  return(0);
}
Ejemplo n.º 7
0
static void printUsage()
{
    printOut(LR::tr(
        "Usage:\n"
        "    lrelease [options] project-file\n"
        "    lrelease [options] ts-files [-qm qm-file]\n\n"
        "lrelease is part of Qt's Linguist tool chain. It can be used as a\n"
        "stand-alone tool to convert XML-based translations files in the TS\n"
        "format into the 'compiled' QM format used by QTranslator objects.\n\n"
        "Options:\n"
        "    -help  Display this information and exit\n"
        "    -idbased\n"
        "           Use IDs instead of source strings for message keying\n"
        "    -compress\n"
        "           Compress the QM files\n"
        "    -nounfinished\n"
        "           Do not include unfinished translations\n"
        "    -removeidentical\n"
        "           If the translated text is the same as\n"
        "           the source text, do not include the message\n"
        "    -markuntranslated <prefix>\n"
        "           If a message has no real translation, use the source text\n"
        "           prefixed with the given string instead\n"
        "    -silent\n"
        "           Do not explain what is being done\n"
        "    -version\n"
        "           Display the version of lrelease and exit\n"
    ));
}
Ejemplo n.º 8
0
//solve measure
void sudoSolve(int step)
{
	int i,j,k;
	bool flag;
	if(step>=81){
		printOut();
		return ;
	}
	j=step/9;
	i=step%9;
	if(sudoOut[j][i]!=0)
		sudoSolve(step+1);
	else{
		for(k=1;k<=9;k++){
			if(book[j][k]==0){
				flag=rightDefine(j,i,k);
				if(flag){
						book[j][k]=1;
						sudo[j][i]=k;
						sudoSolve(step+1);
						book[j][k]=0;
						sudo[j][i]=sudoOut[j][i];
					}
			}
		}
	}
}
Ejemplo n.º 9
0
int main()
{
	char **array;
	array = malloc(9 * sizeof(char *));
	for (int i = 0; i < 9; i++)
	{
		array[i] = malloc(9 * sizeof(char));
		if (array[i] == NULL)
		{
			fprintf(stderr, "out of memory\n");
			exit(EXIT_FAILURE);
		}
	}

	for (int i = 0; i < 9; ++i)
		for (int j = 0; j < 9; ++j)
			array[i][j] = input[i][j];

	solveSudoku(array, 9, 9);
	printOut(array);

	for (int i = 0; i < 9; ++i)
		free(array[i]);
	free(array);
	return 0;
}
// The list tree function runs through all objects in the ASDK_DICT dictionary,
// follows their ownership trees, and lists out information
// on all objects in the tree.
//
void
listTree()
{
    AcDbDictionary *pNamedobj;
    AcDbDictionary *pDict;
    acdbHostApplicationServices()->workingDatabase()
        ->getNamedObjectsDictionary(pNamedobj, AcDb::kForWrite);

    // Get a pointer to the ASDK_DICT dictionary.
    //
    if (pNamedobj->getAt(_T("ASDK_DICT"), (AcDbObject*&) pDict,
        AcDb::kForRead) == Acad::eKeyNotFound)
	{
		pNamedobj->close();
		return ;
	}

    pNamedobj->close();

    // Run through the entries and list their backpointers.
    //
    AcDbDictionaryIterator *pDictItr = pDict->newIterator();
    for (; !pDictItr->done(); pDictItr->next()) {
        printOut(pDictItr->objectId());
    }
    delete pDictItr;

    pDict->close();
}
Ejemplo n.º 11
0
Archivo: main.cpp Proyecto: maxxant/qt
static void printUsage()
{
    printOut(LU::tr(
        "Usage:\n"
        "    lupdate [options] [project-file]...\n"
        "    lupdate [options] [source-file|path|@lst-file]... -ts ts-files|@lst-file\n\n"
        "lupdate is part of Qt's Linguist tool chain. It extracts translatable\n"
        "messages from Qt UI files, C++, Java and JavaScript/QtScript source code.\n"
        "Extracted messages are stored in textual translation source files (typically\n"
        "Qt TS XML). New and modified messages can be merged into existing TS files.\n\n"
        "Options:\n"
        "    -help  Display this information and exit.\n"
        "    -no-obsolete\n"
        "           Drop all obsolete strings.\n"
        "    -extensions <ext>[,<ext>]...\n"
        "           Process files with the given extensions only.\n"
        "           The extension list must be separated with commas, not with whitespace.\n"
        "           Default: '%1'.\n"
        "    -pluralonly\n"
        "           Only include plural form messages.\n"
        "    -silent\n"
        "           Do not explain what is being done.\n"
        "    -no-sort\n"
        "           Do not sort contexts in TS files.\n"
        "    -no-recursive\n"
        "           Do not recursively scan the following directories.\n"
        "    -recursive\n"
        "           Recursively scan the following directories (default).\n"
        "    -I <includepath> or -I<includepath>\n"
        "           Additional location to look for include files.\n"
        "           May be specified multiple times.\n"
        "    -locations {absolute|relative|none}\n"
        "           Specify/override how source code references are saved in TS files.\n"
        "           Default is absolute.\n"
        "    -no-ui-lines\n"
        "           Do not record line numbers in references to UI files.\n"
        "    -disable-heuristic {sametext|similartext|number}\n"
        "           Disable the named merge heuristic. Can be specified multiple times.\n"
        "    -pro <filename>\n"
        "           Name of a .pro file. Useful for files with .pro file syntax but\n"
        "           different file suffix. Projects are recursed into and merged.\n"
        "    -source-language <language>[_<region>]\n"
        "           Specify the language of the source strings for new files.\n"
        "           Defaults to POSIX if not specified.\n"
        "    -target-language <language>[_<region>]\n"
        "           Specify the language of the translations for new files.\n"
        "           Guessed from the file name if not specified.\n"
        "    -ts <ts-file>...\n"
        "           Specify the output file(s). This will override the TRANSLATIONS\n"
        "           and nullify the CODECFORTR from possibly specified project files.\n"
        "    -codecfortr <codec>\n"
        "           Specify the codec assumed for tr() calls. Effective only with -ts.\n"
        "    -version\n"
        "           Display the version of lupdate and exit.\n"
        "    @lst-file\n"
        "           Read additional file names (one per line) from lst-file.\n"
    ).arg(m_defaultExtensions));
}
Ejemplo n.º 12
0
NdbOut& operator<<(NdbOut& no, const CommitTransactionRecord& ctr) {
  no << "----------COMMIT TRANSACTION RECORD------------" << endl << endl;
  printOut("Record type:", ctr.m_recordType);
  printOut("TableId", ctr.m_tableId);
  printOut("SchemaVersion:", ctr.m_schemaVersion);
  printOut("FfragmentId", ctr.m_fragmentId);
  printOut("File no. of Prep. Op.", ctr.m_fileNumberOfPrepareOperation);
  printOut("Start page no. of Prep. Op.", ctr.m_startPageNumberOfPrepareOperation);
  printOut("Start page index of Prep. Op.", ctr.m_startPageIndexOfPrepareOperation);
  printOut("Stop page no. of Prep. Op.", ctr.m_stopPageNumberOfPrepareOperation);
  printOut("GlobalCheckpoint", ctr.m_globalCheckpoint);

  no << endl;
  return no;
}
Ejemplo n.º 13
0
void main()
{
	int a, b, c, d;

	enter(&a, &b, &c, &d);
	printOut(a, b, c, d);
	printf("Your largest number is %d\n\n", large(a, b, c, d));
	sort(a, b, c, d);

	system("PAUSE");
}
Ejemplo n.º 14
0
Archivo: main.cpp Proyecto: Fale/qtmoko
static bool loadTsFile(Translator &tor, const QString &tsFileName, bool /* verbose */)
{
    ConversionData cd;
    bool ok = tor.load(tsFileName, cd, QLatin1String("auto"));
    if (!ok) {
        qWarning("lrelease error: %s\n", qPrintable(cd.error()));
    } else {
        if (!cd.errors().isEmpty())
            printOut(cd.error());
    }
    return ok;
}
Ejemplo n.º 15
0
void program2()
{
    load();
    initEmit();
    getToken();
    block();
    if (token.sym != periodsym)
        getError(0);
    emit(9, 0, 2);
    printOut();
    closeEmit();
    printf("The program is syntactically correct.");
}
Ejemplo n.º 16
0
void *thread2() {
//	printOut(itoa(mythread_self(),10));
//	printOut(": Thread2\n");
	int i=0;
	while(i<200) {
  		mythread_mutex_lock(&lock);
		glval++;
		if(glval==100) {
			printOut("Thread2 sleeping for 10000 microseconds to hit blocking mutex condition in thread1\n");
			mythread_cond_signal(&cond);
			mythread_cond_broadcast(&cond1);

			usleep(10000);

		}

		mythread_mutex_unlock(&lock);
		printOut("Using IO in thread2 \n");
		i++;
	}

}
Ejemplo n.º 17
0
static bool loadTsFile(Translator &tor, const QString &tsFileName, bool /* verbose */)
{
    ConversionData cd;
    bool ok = tor.load(tsFileName, cd, QLatin1String("auto"));
    if (!ok) {
        printErr(LR::tr("lrelease error: %1").arg(cd.error()));
    } else {
        if (!cd.errors().isEmpty())
            printOut(cd.error());
    }
    cd.clearErrors();
    return ok;
}
Ejemplo n.º 18
0
void doit(int thresh, int varmax, MR_ROBDD_type *f)
    {
	MR_ROBDD_type *result;
#ifdef DEBUGALL
	printf("MR_ROBDD_restrictThresh(%d, [%d,]", thresh, varmax-1),
	printOut(f),
	printf(") =");
	fflush(stdout);
#endif /* DEBUGALL */
#ifndef OVERHEAD
#if !defined(MR_ROBDD_USE_THRESH) && !defined(MR_ROBDD_RESTRICT_SET)
	result = MR_ROBDD_restrictThresh(thresh, varmax-1, f);
#else /* MR_ROBDD_USE_THRESH */
	result = MR_ROBDD_restrictThresh(thresh, f);
#endif /* MR_ROBDD_OLD */
#ifdef DEBUGALL
	printOut(result);
	printf("\n");
#endif /* DEBUGALL */
#endif /* !OVERHEAD */
	++opcount;
    }
Ejemplo n.º 19
0
static bool releaseTranslator(Translator &tor, const QString &qmFileName,
    bool verbose, bool ignoreUnfinished,
    bool removeIdentical, TranslatorSaveMode mode)
{
    Translator::reportDuplicates(tor.resolveDuplicates(), qmFileName, verbose);

    if (verbose)
        printOut(QCoreApplication::tr( "Updating '%1'...\n").arg(qmFileName));
    if (removeIdentical) {
        if ( verbose )
            printOut(QCoreApplication::tr( "Removing translations equal to source text in '%1'...\n").arg(qmFileName));
        tor.stripIdenticalSourceTranslations();
    }

    QFile file(qmFileName);
    if (!file.open(QIODevice::WriteOnly)) {
        qWarning("lrelease error: cannot create '%s': %s\n",
                 qPrintable(qmFileName), qPrintable(file.errorString()));
        return false;
    }

    ConversionData cd;
    tor.normalizeTranslations(cd);
    cd.m_verbose = verbose;
    cd.m_ignoreUnfinished = ignoreUnfinished;
    cd.m_saveMode = mode;
    bool ok = tor.release(&file, cd);
    file.close();

    if (!ok) {
        qWarning("lrelease error: cannot save '%s': %s\n",
                 qPrintable(qmFileName), qPrintable(cd.error()));
        return false;
    } else if (!cd.errors().isEmpty()) {
        printOut(cd.error());
    }
    return true;
}
Ejemplo n.º 20
0
static void printUsage()
{
    printOut(QObject::tr(
        "Usage:\n"
        "    lupdate [options] [project-file]\n"
        "    lupdate [options] [source-file|path]... -ts ts-files\n\n"
        "lupdate is part of Qt's Linguist tool chain. It can be used as a\n"
        "stand-alone tool to create XML based translations files in the .ts\n"
        "format from translatable messages in C++ and Java source code.\n\n"
        "lupdate can also merge such messages into existing .ts files.\n\n"
        "Options:\n"
        "    -help  Display this information and exit.\n"
        "    -no-obsolete\n"
        "           Drop all obsolete strings.\n"
        "    -extensions <ext>[,<ext>]...\n"
        "           Process files with the given extensions only.\n"
        "           The extension list must be separated with commas, not with whitespace.\n"
        "           Default: '%1'.\n"
        "    -pluralonly\n"
        "           Only include plural form messages.\n"
        "    -silent\n"
        "           Do not explain what is being done.\n"
        "    -no-sort\n"
        "           Do not sort contexts in .ts files.\n"
        "    -no-recursive\n"
        "           Do not recursively scan the following directories.\n"
        "    -recursive\n"
        "           Recursively scan the following directories.\n"
        "    -locations {absolute|relative|none}\n"
        "           Specify/override how source code references are saved in ts files.\n"
        "           Default is absolute.\n"
        "    -no-ui-lines\n"
        "           Do not record line numbers in references to .ui files.\n"
        "    -disable-heuristic {sametext|similartext|number}\n"
        "           Disable the named merge heuristic. Can be specified multiple times.\n"
        "    -pro <filename>\n"
        "           Name of a .pro file. Useful for files with .pro\n"
        "           file syntax but different file suffix\n"
        "    -source-language <language>[_<region>]\n"
        "           Specify/override the language of the source strings. Defaults to\n"
        "           POSIX if not specified and the file does not name it yet.\n"
        "    -target-language <language>[_<region>]\n"
        "           Specify/override the language of the translation.\n"
        "           The target language is guessed from the file name if this option\n"
        "           is not specified and the file contents name no language yet.\n"
        "    -version\n"
        "           Display the version of lupdate and exit.\n"
    ).arg(m_defaultExtensions));
}
Ejemplo n.º 21
0
Archivo: aes.c Proyecto: prabhaks/AES
/*
 * This method performs encrypt operation given plaintext.
 * It read tables from tf and plaintext from fp.
 * Encrypts plainetxt using key
 */
void ProcessEncrypt(char *key, FILE *tf, FILE *fp) {
	table_check = 0;
	ProcessTableCheck(tf);
	char buf[16];
	int ret = fread(buf, 1, 16, fp);
	if (ret < 16) {
		fprintf(stderr,
				"Input size for encryption can not be less than 16 bytes\n");
		exit(1);
	}
	int i, Nr = 10, Nb = 4, round;
	unsigned char **state = (unsigned char **) malloc(
			sizeof(unsigned char *) * 4);
	for (i = 0; i < 4; i++)
		state[i] = (unsigned char *) malloc(sizeof(unsigned char) * 4);
	copyInStateArray(state, buf);
	unsigned char **word = doProcessKeyExpand(key);
	printOut(state, "input", 0);
	AddRoundKey(state, word, 0);
	printWord(word, "k_sch", 0, 0);
	for (round = 1; round < Nr; round++) {
		printOut(state, "start", round);
		SubBytes(state);
		printOut(state, "s_box", round);
		ShiftRows(state);
		printOut(state, "s_row", round);
		MixColumns(state, P);
		printOut(state, "m_col", round);
		AddRoundKey(state, word, round * Nb);
		printWord(word, "k_sch", round * Nb, round);
	}
	printOut(state, "start", round);
	SubBytes(state);
	printOut(state, "s_box", round);
	ShiftRows(state);
	printOut(state, "s_row", round);
	AddRoundKey(state, word, Nr * Nb);
	printWord(word, "k_sch", Nr * Nb, round);
	printOut(state, "output", round);
}
Ejemplo n.º 22
0
void doit(int w, MR_ROBDD_type *f)
    {
	int result;

#ifdef DEBUGALL
	printf("MR_ROBDD_var_entailed(");
	printOut(f),
	printf(", %d) = ", w);
	fflush(stdout);
#endif /* DEBUGALL */
#ifndef OVERHEAD
	result = MR_ROBDD_var_entailed(f, w);
#ifdef DEBUGALL
	printf("%s\n", (result ? "true" : "false"));
#endif /* DEBUGALL */
#endif /* !OVERHEAD */
	++opcount;
    }
Ejemplo n.º 23
0
static void printUsage()
{
    printOut( QObject::tr(
        "Creates or updates eZ Publish translations.\n"
        "Usage: ezlupdate [OPTION]... LANGUAGE\n\n"
        "Options:\n"
        "    -h, --help                Display this information and exit\n"
        "    -e, --extension EXT       Extension mode. Scans extension EXT instead of\n"
        "                              kernel, lib and design\n"
        "    -d, --dirs DIR [DIR]...   Directories to scan in addition to kernel, lib\n"
        "                              and designs\n"
        "    -u, --untranslated        Create/update the untranslated file as well\n"
        "    -no, --noobsolete         Drop all obsolete strings\n"
        "    --utf8                    Assume UTF8 when the encoding is uncertain\n"
        "    -v, --verbose             Explain what is being done\n"
        "    --version                 Display the version of ezlupdate and exit\n"
    ) );
}
Ejemplo n.º 24
0
void Sudoku::solve(){
	int i,j;
	ansCount=0;

	for(i=0;i<81;i=i+9){//test if the sudoku can be solved
		getRow(i,sudokuIn);
		if(checkUnity(arr_check)==false){
			cout << "0"
				 << endl;
	 		return;
	 	}
	 	getCol(i,sudokuIn);
	 	if(checkUnity(arr_check)==false){
			cout << "0"
				 << endl;
	 		return;
	 	}
	 	getCell(i,sudokuIn);
	 	if(checkUnity(arr_check)==false){
			cout << "0"
				 << endl;
	 		return;
	 	}
	}

	for(i=0;i<81;i++){
		answerBoard[i]=sudokuIn[i];
	}

	fillBlank();

	if(ansCount==1){
		cout << "1" << endl;
		printOut(keepAns);
	}
	else if(ansCount==0)
		cout << "0";
	else if(ansCount==2){
		cout << "2";
	}
};
Ejemplo n.º 25
0
void EditMap(){
  string input = requestInput("Would you like to edit an [Old] map or a [New] map");
  string mapFiles = "mapfiles/";
  string file;
  if(input == "New" || input == "new"){
    int rows;
    int columns;
    printf("\nhow many columns would you like your map to have?\n");
    printf(">");
    cin >> columns;
    printf("\nhow many rows would you like your map to have?\n");
    printf(">");
    cin >> rows;
    Map editable = Map(rows,columns);
    editable.setEditable(true);
    Display dis(100,100,DEFAULT_SCALE);
    MapObserver* obs = new MapObserver(&editable,&dis);
    file = editable.mapeditor(&dis);
    printOut("Finished editing: " + file + " returning to main menu");
    return;
  }
Ejemplo n.º 26
0
void block::printData(string part,ofstream* k,int t,map<string,bool> * printed, bool printIn){
	string buffer;
	cout << filename << " is the base filename" << endl;
	if(filename.compare("null")){
		//-------- open the file where the end routines are located
		ifstream f(ofToDataPath(ROOT_DIR+"/blocks/"+filename).c_str());
		//-------- burn the buffer until we find the start of the end
		bool found=false;
		while(f.peek()!=EOF&&!found){
			if (buffer.compare(part)) {
				getline(f,buffer);
			}
			else {
				found=true;
			}
		}
		if(found){
			//-------- printout the code for the start routines
			printOut(k,&f,t,printed);
			//-------- set the printed flag for the block and close the input 
			(*printed)[title]=true;
			f.close();
			
			//-------- print the start routines for the blocks on and in
			if(printIn)
				for (unsigned int i=0; i<blocksIn.size(); i++) {
					blocksIn[i].printData(part,k,t,printed,printIn);
				}
			for (unsigned int i=0; i<blocksOn.size(); i++) {
				blocksOn[i].printData(part,k,t,printed,printIn);
			}
		}
	}
	else {
		for (unsigned int i=0; i<blocksOn.size(); i++) {
			blocksOn[i].printData(part,k,t,printed,printIn);
		}
	}

}
Ejemplo n.º 27
0
/*void Sudoku::giveQuestion(){
	int ans[9][9] = {{0,0,0,0,0,0,0,0,0}\
			,{0,0,0,0,0,0,0,0,0}\
			,{0,0,0,0,0,0,0,0,0}\
			,{0,0,0,0,0,0,0,0,0}\
			,{0,0,0,0,0,0,0,0,0}\
			,{0,0,0,0,0,0,0,0,0}\
			,{0,0,1,0,0,0,0,0,0}\
			,{0,0,0,0,0,1,0,0,0}\
			,{0,0,0,0,0,0,2,3,4}};	
	int ans[9][9] = {{0,0,0,0,0,0,0,1,0}\
			,{4,0,0,0,0,0,0,0,0}\
			,{0,2,0,0,0,0,0,0,0}\
			,{0,0,0,0,5,0,4,0,7}\
			,{0,0,8,0,0,0,3,0,0}\
			,{0,0,1,0,9,0,0,0,0}\
			,{3,0,0,4,0,0,2,0,0}\
			,{0,5,0,1,0,0,0,0,0}\
			,{0,0,0,8,0,6,0,0,0}};
	for(int i=0; i<9; i++)
		for(int j=0; j<9; j++)
			printf("%d%c", ans[i][j], (j!=8)?' ':'\n');
}*/
void Sudoku::giveQuestion(){
	srand(time(NULL));
	int i, j, cnt;
	int ans[9][9] = {{1,2,3,4,5,6,7,8,9}\
			,{4,5,6,7,8,9,1,2,3}\
			,{7,8,9,1,2,3,4,5,6}\
			,{2,1,4,3,6,5,8,9,7}\
			,{3,6,5,8,9,7,2,1,4}\
			,{8,9,7,2,1,4,3,6,5}\
			,{5,3,1,6,4,2,9,7,8}\
			,{6,4,2,9,7,8,5,3,1}\
			,{9,7,8,5,3,1,6,4,2}};
	//random answer
	for(i=0; i<9; i++)
		for(j=0; j<9; j++){
			grid[i][j]=ans[i][j];
			ans[i][j]=0;
		}
	change();	
	for(i=0; i<9; i++)
		for(j=0; j<9; j++)
			ans[i][j]=grid[i][j];
	//fill in the answer randomly
	//prevent multi-solution by answer()
	do{
		for(i=0; i<9; i++)
			for(j=0; j<9; j++)
				grid[i][j]=0;
		cnt=0;
		while(cnt<30 || !answer(1)){
			do{
				i=rand()%9;
				j=rand()%9;
			}while(grid[i][j]!=0);
			grid[i][j]=ans[i][j];
			cnt++;
		}
	}while(cnt>40);
	printOut(true);
}
Ejemplo n.º 28
0
void Sudoku::solve() {
   int i, result = 0;
   int test = nextBlank(-1);

   if(initial_check()==false) test=sudokuSize;
   else
      if(test==sudokuSize){
            result = 1;
            for(i=0; i<sudokuSize; ++i) ans[i] = map[i];
      }

   while(test>=0 && test<sudokuSize && result<2){
      map[test]++;
      if(map[test]>9){
         map[test] = 0;
         test = pop();
      }
      else{
         if(check(test)==true){
            blankNum[fillPoint++] = test;
            test=nextBlank(test);
            if(test==sudokuSize){
               result++;
               for(i=0; i<sudokuSize; ++i) ans[i] = map[i];
               test = pop();
            }
         }
      }
   }

   if(result==1){
        cout << "1" << endl;
        printOut(true);
   }
   else if(result>1) cout << "2";
   else
        cout << "0";

}
Ejemplo n.º 29
0
Archivo: main.cpp Proyecto: Fale/qtmoko
static void printUsage()
{
    printOut(QCoreApplication::tr(
        "Usage:\n"
        "    lrelease [options] project-file\n"
        "    lrelease [options] ts-files [-qm qm-file]\n\n"
        "lrelease is part of Qt's Linguist tool chain. It can be used as a\n"
        "stand-alone tool to convert XML based translations files in the .ts\n"
        "format into the 'compiled' .qm format used by QTranslator objects.\n\n"
        "Options:\n"
        "    -help  Display this information and exit\n"
        "    -compress\n"
        "           Compress the .qm files\n"
        "    -nounfinished\n"
        "           Do not include unfinished translations\n"
        "    -removeidentical\n"
        "           If the translated text is the same as\n"
        "           the source text, do not include the message\n"
        "    -silent\n"
        "           Don't explain what is being done\n"
        "    -version\n"
        "           Display the version of lrelease and exit\n"
    ));
}
Ejemplo n.º 30
0
Archivo: main.cpp Proyecto: Fale/qtmoko
int main(int argc, char **argv)
{
    QCoreApplication app(argc, argv);
    QStringList args = app.arguments();
    QTranslator translator;
    if (translator.load(QLatin1String("lrelease_") + QLocale::system().name()))
        app.installTranslator(&translator);

    bool verbose = true; // the default is true starting with Qt 4.2
    bool ignoreUnfinished = false;
    // the default mode is SaveEverything starting with Qt 4.2
    TranslatorSaveMode mode = SaveEverything;
    bool removeIdentical = false;
    Translator tor;
    QString outputFile;
    int numFiles = 0;

    for (int i = 1; i < argc; ++i) {
        if (args[i] == QLatin1String("-compress")) {
            mode = SaveStripped;
            continue;
        } else if (args[i] == QLatin1String("-nocompress")) {
            mode = SaveEverything;
            continue;
        } else if (args[i] == QLatin1String("-removeidentical")) {
            removeIdentical = true;
            continue;
        } else if (args[i] == QLatin1String("-nounfinished")) {
            ignoreUnfinished = true;
            continue;
        } else if (args[i] == QLatin1String("-silent")) {
            verbose = false;
            continue;
        } else if (args[i] == QLatin1String("-verbose")) {
            verbose = true;
            continue;
        } else if (args[i] == QLatin1String("-version")) {
            printOut(QCoreApplication::tr( "lrelease version %1\n").arg(QLatin1String(QT_VERSION_STR)) );
            return 0;
        } else if (args[i] == QLatin1String("-qm")) {
            if (i == argc - 1) {
                printUsage();
                return 1;
            }
            i++;
            outputFile = args[i];
        } else if (args[i] == QLatin1String("-help")) {
            printUsage();
            return 0;
        } else if (args[i][0] == QLatin1Char('-')) {
            printUsage();
            return 1;
        } else {
            numFiles++;
        }
    }

    if (numFiles == 0) {
        printUsage();
        return 1;
    }

    for (int i = 1; i < argc; ++i) {
        if (args[i][0] == QLatin1Char('-') || args[i] == outputFile)
            continue;

        if (args[i].endsWith(QLatin1String(".pro"), Qt::CaseInsensitive)
            || args[i].endsWith(QLatin1String(".pri"), Qt::CaseInsensitive)) {
            QHash<QByteArray, QStringList> varMap;
            bool ok = evaluateProFile(args[i], verbose, &varMap );
            if (ok) {
                QStringList translations = varMap.value("TRANSLATIONS");
                if (translations.isEmpty()) {
                    qWarning("lrelease warning: Met no 'TRANSLATIONS' entry in"
                             " project file '%s'\n",
                             qPrintable(args[i]));
                } else {
                    foreach (const QString &trans, translations)
                        if (!releaseTsFile(trans, verbose, ignoreUnfinished, removeIdentical, mode))
                            return 1;
                }
            } else {
                qWarning("error: lrelease encountered project file functionality that is currently not supported.\n"
                    "You might want to consider using .ts files as input instead of a project file.\n"
                    "Try the following syntax:\n"
                    "    lrelease [options] ts-files [-qm qm-file]\n");
            }
        } else {