void initilize() { handle = GetStdHandle(STD_OUTPUT_HANDLE); for (int i = 0; i < HEIGHT + 2; ++i) { for (int j = 0; j < WIDTH + 2; ++j) { if (i == 0 || j == 0 || i == HEIGHT + 1 || j == WIDTH + 1) printBlock(FULL); else map[i - 1][j - 1] ? printBlock(FULL) : printBlock(EMPTY); } printf("\n"); } }
void printMap(SDL_Window* window,block **map, int selectedItem, Player* player){ int i,j; block currentBloc, blockVoid; int nbBlocX = NB_LIGNE; int nbBlocY = NB_COLONNE; blockVoid.type = VOID; blockVoid.back = SKY; for(i=0 ; i<nbBlocX ;i++){ for(j = 0 ; j<nbBlocY ; j++){ int mapX = player->position[0] - (nbBlocX/2) +i; int mapY = player->position[1] - (nbBlocY/2) + j; if((mapX >= 0) && (mapX < SIZE_MAX_X) && (mapY >= 0) && (mapY < SIZE_MAX_Y)){ currentBloc = map[mapX][mapY]; } else{ currentBloc = blockVoid; } printBlock(window, currentBloc, i*24, j*24, false); } } printInventory(window,selectedItem,player); //SDL_UpdateWindowSurface(window); }
void Ast2SrcVisitor::visitBlockNode(BlockNode* node) { _out << "{" << std::endl; _indent += _indentSize; printBlock(node); _indent -= _indentSize; _out << std::string(_indent, ' ') << "}";// << std::endl; }
void ForStemnt::print(std::ostream& out, int level) const { if (Project::gDebug) { out << "/* ForStemnt:" ; location.printLocation(out) ; out << " */" << std::endl; } LabelVector::const_iterator j; for (j=labels.begin(); j != labels.end(); j++) (*j)->print(out,level); indent(out,level); out << "for ("; if (init) out << *init; out << "; "; if (cond) out << *cond; out << "; "; if (incr) out << *incr; out << ")\n"; printBlock(out,level,block); }
void DoWhileStemnt::print(std::ostream& out, int level) const { if (Project::gDebug) { out << "/* DoWhileStemnt:" ; location.printLocation(out) ; out << " */" << std::endl; } LabelVector::const_iterator j; for (j=labels.begin(); j != labels.end(); j++) (*j)->print(out,level); indent(out,level); out << "do "; if (!block->isBlock()) out << std::endl; printBlock(out,level,block); if (!block->isBlock()) out << std::endl; indent(out,level); out << "while (" << *cond << ")"; }
void PrettyPrinter::visitBlockNode(BlockNode *node) { std::string indentation(m_indent, ' '); m_out << indentation << "{" << std::endl; m_indent += 4; printBlock(node); m_out << indentation << "}"; m_indent -= 4; }
void Configuration::dump() { Serial.println(F("\nClient Configuration:")); Serial.print(F("Version : ")); Serial.println(version, HEX); Serial.print(F("Node ID : ")); Serial.println(nodeId, HEX); Serial.print(F("Number LEDs : ")); Serial.println(numberLeds); Serial.print(F("WIFI Tries : ")); Serial.println(wifiTries); Serial.print(F("MQTT Tries : ")); Serial.println(mqttTries); Serial.print(F("SSID : ")); printBlock( ssid, STRING_SIZE ); Serial.print(F("Password : "******"Server Address : ")); printBlock( serverAddress, STRING_SIZE ); Serial.print(F("All Channel : ")); printBlock( allChannel, STRING_SIZE ); Serial.print(F("Reg Channel : ")); printBlock( regChannel, STRING_SIZE ); Serial.print(F("My Channel : ")); printBlock( myChannel, STRING_SIZE ); Serial.print(F("Response Channel: ")); printBlock( myResponseChannel, STRING_SIZE ); Serial.print(F("CRC : ")); Serial.println(crc, HEX); }
/* * printFreeList - prentar ut allar blokkir sem eru free * notadi thetta til ad idebuga med tvi ad prenta ut allar blokkir thegar mm_check() * var ekki til. */ void printFreeList() { void* bp; printf("------ FREE LIST START -------\n"); for (bp = (heap_listp+2*WSIZE); GET_SIZE(HDRP(bp)) > 0; bp = NEXT_BLKP(bp)) { if(!GET_ALLOC(HDRP(bp))) printBlock(bp); } printf("------ FREE LIST END -------\n"); }
/* * printAllBlock - prentar ut allar blokkir a heap * notadi thetta til ad idebuga med tvi ad prenta ut allar blokkir thegar mm_check() * var ekki til. */ void printAllBlock() { void* bp; printf("------ ALL BLOCK -------\n"); for (bp = (heap_listp+(2*WSIZE)); GET_SIZE(HDRP(bp)) > 0; bp = NEXT_BLKP(bp)) { printBlock(bp); } printf("------ BLOCKST END -------\n"); }
void PQueue<ElementType, PriorityType>::printQueue() const { auto cur = root; std::cout << "PQueue:" << std::endl; while (cur != nullptr) { cur->printBlock(); std::cout << std::endl; cur = cur->next; } }
/*! \fn void aes256CtrTest(void) * \brief Perform a CTR test using test vectors found in * http://csrc.nist.gov/publications/nistpubs/800-38a/sp800-38a.pdf * page 57 */ void aes256CtrTest(void) { // init aes256CtrCtx_t ctx; aes256CtrInit(&ctx, key, iv, 16); // Encrypt init string printTextP(PSTR("CTR-AES256Encrypt")); // Print key printKey(key); // Encrypt TEST 1 printBlock(1); printEncryptTest(&ctx, v1, 16); // Encrypt TEST 2 printBlock(2); printEncryptTest(&ctx, v2, 16); // Encrypt TEST 3 printBlock(3); printEncryptTest(&ctx, v3, 16); // Encrypt TEST 4 printBlock(4); printEncryptTest(&ctx, v4, 16); // Decrypt init string printTextP(PSTR("\n\nCTR-AES256Decrypt")); aes256CtrSetIv(&ctx, iv, 16); // print key printKey(key); // Encrypt TEST 1 printBlock(1); printDecryptTest(&ctx, v1, 16); // Encrypt TEST 2 printBlock(2); printDecryptTest(&ctx, v2, 16); // Encrypt TEST 3 printBlock(3); printDecryptTest(&ctx, v3, 16); // Encrypt TEST 4 printBlock(4); printDecryptTest(&ctx, v4, 16); }
int main(void) { initHeap(); initHeap(); printBlock((struct MemBlock*)memPool); printf("Adresse: %p \n", memPool); printf("Absolute Adresse: %p \n",rel_to_Abs(7)); printf("Relative Adresse: %d \n",abs_to_Rel(0x404107)); printFreeBlocks(); return EXIT_SUCCESS; }
void printFreeBlocks(void) { struct MemBlock *temp=freeMem; while(temp != NULL) { printBlock(temp); if(temp->next != NULL) { temp=temp->next; } else { temp=NULL; } } }
void main() { int ch; x = 5; /*처음 좌표 */ y = 2; noCursor(); /* 커서 지움 */ printMap(); /* 맵 그리기 */ printBlock(); /* 블록 출력 */ for (; 1;) { //블록 움직임 반복 if (kbhit()) { // 키입력 처리 --------------------------------- clearBlock(); ch = getch(); if (ch == 0xE0) { //방향키를 눌럿을 때× ch = getch(); switch (ch) { case LEFT: x--; break; case RIGHT: x++; break; case DOWN: y++; break; case UP: sh++; if (sh > 3) sh = 0; break; } } printBlock(); } // ------------------- 키입력 처리 종료 Sleep(100); /* 0.1초간 대기 */ } }
void printFreeBlocks(void) { /*Gibt alle Bloecke aus*/ if (!freeMem) { printf("Keine freien Bloecke!"); } else { memBlock *mBlock = freeMem; printf("===============================================================================\n"); printf("|StartRel|StartAbs|Mem_Size|Use_Rel.|Use_Abs.|Use_Size| Size | Next |State|\n"); printf("|--------|--------|--------|--------|--------|--------|--------|--------|-----|\n"); while (mBlock != NULL) { printBlock(mBlock); mBlock = mBlock->next; /*Nechster memBlock*/ } printf("===============================================================================\n"); } }
std::string prettyPrint(const ModuleBase& module) { std::stringstream out; out << "@version " << module.version(); if (module.onInit()) out << "\n@onInit " << module.onInit()->name(); if (module.onPacket()) out << "\n@onPacket " << module.onPacket()->name(); if (module.onPeriodic()) out << "\n@onPeriodic " << module.onPeriodic()->name(); for (auto* b : module.blocks()) printBlock(b, out << "\n\n"); return out.str(); }
void printInventory(SDL_Window* window, int selectedItem, Player* player){ int i = 0; int x = (WIDTH / 2) - 80; int y = HEIGHT - 40; for(i=0 ; i<4; i++){ SDL_Rect rect ={x +(i * 40), y, 40, 40}; SDL_BlitSurface(frameBmp,NULL,SDL_GetWindowSurface(window), &rect); } SDL_Rect rect ={x +(40 * selectedItem), y, 40, 40}; SDL_BlitSurface(selectedBmp,NULL,SDL_GetWindowSurface(window), &rect); for(i =0 ; i < 4 ; i++){ if(player->inventory[i].desc.type !=NONE){ int blocX = x + (i * 40) + 8; int blocY = y + 8; printBlock(window,player->inventory[i].desc, blocX, blocY, true); } } }
static void * printToFile(void * args) { TeeMultiplexerData * data = (TeeMultiplexerData *) args; // Wait for first block to arrive pthread_mutex_lock(&data->continue_mutex); if (data->count == 0 && !data->done) pthread_cond_wait(&data->continue_cond, &data->continue_mutex); pthread_mutex_unlock(&data->continue_mutex); if (data->count < 0) return NULL; while(data->dataBlocks) { printBlock(data->infile, data->outfile, data->dataBlocks); if (goToNextBlock(data)) return NULL; } return NULL; }
int main(int argc, char** argv) { size_t dataSize = 10; unsigned char data[dataSize]; memset(data, 0, dataSize); // Store key. size_t mdSize = SHA256_DIGEST_LENGTH; unsigned char md[mdSize]; SHA256_CTX c; SHA224_Init(&c); SHA224_Update(&c, data, dataSize); SHA224_Final(md, &c); printBlock(md, mdSize); printf("\n"); return 0; }
void SwitchStemnt::print(std::ostream& out, int level) const { if (Project::gDebug) { out << "/* SwitchStemnt:" ; location.printLocation(out) ; out << " */" << std::endl; } LabelVector::const_iterator j; for (j=labels.begin(); j != labels.end(); j++) (*j)->print(out,level); indent(out,level); out << "switch (" << *cond << ")\n"; printBlock(out,level,block); }
//Change number to binary form int doBinChange(SuDoku_block* block) { #if defined DEBUG printf ("Enter doBinChange().\n"); #endif int i,j; int temp = 0; if (NULL == block){ printf ( "Block is NULL.\n" ); return SUDOKU_NG; } //change Number to binary system for (i=0;i<9;i++){ for (j=0;j<9;j++){ if ( 0==block->point[i][j][0] ){ block->point[i][j][0] = 511; block->point[i][j][1] = 9; } else { temp = block->point[i][j][0] - 1; block->point[i][j][0] = 1 << temp; block->point[i][j][1] = 1; block->number ++; } }//end for j }//end for i #if defined DEBUG printf ( "blockOKNumber init is %d.\n",block->number ); printBlock ( block ); #endif #if defined DEBUG printf ("DoBinChange() ended.\n"); #endif return SUDOKU_OK; }
/** * Check the heap for consistency. * HELPER FUNCTION * @param - int verbose */ void mm_checkheap(int verbose){ void *bp = heap_listp; if (verbose) { printf("Heap (%p):\n", heap_listp); } if (((GET_HSIZE(heap_listp)) != BLKSIZE) || !GET_HALLOC(heap_listp)){ printf("Bad prologue header\n"); } checkBlock(heap_listp); for (bp = listp; GET_HALLOC(bp) == 0; bp = NEXT_PTR(bp)) { if (verbose){ printBlock(bp); } checkBlock(bp); } if ((GET_HSIZE(bp) != 0) || !(GET_HALLOC(bp))){ printf("Bad epilogue header\n"); } }
int Write ( sEvent *sp, FILE *outFile ) { switch (sp->EventType) { case mh_eEvent_Alarm: case mh_eEvent_MaintenanceAlarm: case mh_eEvent_SystemAlarm: case mh_eEvent_UserAlarm1: case mh_eEvent_UserAlarm2: case mh_eEvent_UserAlarm3: case mh_eEvent_UserAlarm4: case mh_eEvent_Info: printMess(sp, outFile); break; case mh_eEvent_Ack: printAck(sp, outFile); break; case mh_eEvent_Cancel: case mh_eEvent_Return: printRet(sp, outFile); break; case mh_eEvent_Block: case mh_eEvent_Unblock: case mh_eEvent_Reblock: case mh_eEvent_CancelBlock: printBlock(sp, outFile); break; default: printf("rt_elog_dump: Error in Write unknown EventType"); break; } return 1; }
void AstPrinter::printTopFunction(AstFunction *top) { printBlock(top->node()->body()); }
void PrettyPrinter::visitTopLevelBlock(AstFunction const * const top) { printBlock(top->node()->body()); }
void ASTAnalyzer::visitBlockNode (BlockNode* node) { output << "{\n"; printScopeDeclarations(node->scope()); printBlock(node); output << "}\n"; }
// Change number to decimal form int doDecChange(SuDoku_block* block) { #if defined DEBUG printf ("Enter doDecChange().\n"); #endif int i,j; if (NULL == block){ printf ( "Block is NULL.\n" ); return SUDOKU_NG; } #if defined DEBUG printf ("blockOKNumber is %d.\n",block->number ); #endif //change Number to decimal system for (i=0;i<9;i++){ for (j=0;j<9;j++){ switch( block->point[i][j][0] ){ case 1: block->point[i][j][0] = 1; break; case 2: block->point[i][j][0] = 2; break; case 4: block->point[i][j][0] = 3; break; case 8: block->point[i][j][0] = 4; break; case 16: block->point[i][j][0] = 5; break; case 32: block->point[i][j][0] = 6; break; case 64: block->point[i][j][0] = 7; break; case 128: block->point[i][j][0] = 8; break; case 256: block->point[i][j][0] = 9; break; default : printf ("Wrong number in %d,%d is %d [binary form].\n",i+1,j+1 ,block->point[i][j][0]); }//end switch }//end for j }//end for i #if defined DEBUG printf ( "blockOKNumber final is %d.\n",block->number ); printBlock ( block ); #endif #if defined DEBUG printf ("DoDecChange() ended.\n"); #endif return SUDOKU_OK; }
//Find the possibility subset of sudoku int findSubset(SuDoku_block* block) { #if defined DEBUG printf ("Enter findSubset().\n"); #endif int i,j,m; int left = 0; int right = 0; int up = 0; int down = 0; unsigned int temp_number = 0; if (NULL == block){ printf ( "Block is NULL.\n" ); return SUDOKU_NG; } #if defined DEBUG printf ( "blockOKNumber before findsubset is %d.\n",block->number ); printBlock ( block ); #endif do { //Findsubset when one point refresh temp_number = block->number ; // Search every point for (i=0;i<9;i++){ for (j=0;j<9;j++){ // Find a subset of unknown point if ( 1 != block->point[i][j][1] ){ // Eliminate the impossible vertical number for ( m=0; m<9; m++ ){ // Only compare to the known point if ( (1 == block->point[i][m][1]) && ( m != j ) ) { if ( 0 != (block->point[i][j][0] & block->point[i][m][0]) ){ //Eliminate this number block->point[i][j][0] &= (~block->point[i][m][0]); block->point[i][j][1]--; if ( 0 == block->point[i][j][0] ){ #if defined DEBUG // Failed to decision,remake decision printf ( "Need re make decision.\n" ); #endif return SUDOKU_RE; } } }//end find known point } //end for m // Eliminate the impossible horizontal number for ( m=0; m<9; m++ ){ // Only compare to the known point if ( (1 == block->point[m][j][1]) && ( m != i ) ) { if ( 0 != (block->point[i][j][0] & block->point[m][j][0]) ){ //Eliminate this number block->point[i][j][0] &= (~block->point[m][j][0]); block->point[i][j][1]--; if ( 0 == block->point[i][j][0] ){ #if defined DEBUG // Failed to decision,remake decision printf ( "Need re make decision.\n" ); #endif return SUDOKU_RE; } } }//end find known point } //end for m // Eliminate the impossible matrix number left = (i%3+1)%3 + i/3*3; right = (i%3+2)%3 + i/3*3; up = (j%3+1)%3 + j/3*3; down = (j%3+2)%3 + j/3*3; //upleft if ( (1 == block->point[left][up][1]) ) { if ( 0 != (block->point[i][j][0] & block->point[left][up][0]) ){ //Eliminate this number block->point[i][j][0] &= (~block->point[left][up][0]); block->point[i][j][1]--; if ( 0 == block->point[i][j][0] ){ #if defined DEBUG // Failed to decision,remake decision printf ( "Need re make decision.\n" ); #endif return SUDOKU_RE; } } //end compare } //downleft if ( (1 == block->point[left][down][1]) ) { if ( 0 != (block->point[i][j][0] & block->point[left][down][0]) ){ //Eliminate this number block->point[i][j][0] &= (~block->point[left][down][0]); block->point[i][j][1]--; if ( 0 == block->point[i][j][0] ){ #if defined DEBUG // Failed to decision,remake decision printf ( "Need re make decision.\n" ); #endif return SUDOKU_RE; } } //end compare } //upright if ( (1 == block->point[right][up][1]) ) { if ( 0 != (block->point[i][j][0] & block->point[right][up][0]) ){ //Eliminate this number block->point[i][j][0] &= (~block->point[right][up][0]); block->point[i][j][1]--; if ( 0 == block->point[i][j][0] ){ #if defined DEBUG // Failed to decision,remake decision printf ( "Need re make decision.\n" ); #endif return SUDOKU_RE; } } //end compare } //downright if ( (1 == block->point[right][down][1]) ) { if ( 0 != (block->point[i][j][0] & block->point[right][down][0]) ){ //Eliminate this number block->point[i][j][0] &= (~block->point[right][down][0]); block->point[i][j][1]--; if ( 0 == block->point[i][j][0] ){ #if defined DEBUG // Failed to decision,remake decision printf ( "Need re make decision.\n" ); #endif return SUDOKU_RE; } } //end compare } //Plus OK number when it unique if ( 1 == block->point[i][j][1] ){ block->number ++; } } //end a unknown point }//end for j }//end for i } while ( (temp_number != block->number) && (81 != block->number) ); #if defined DEBUG printf ( "blockOKNumber after findsubset is %d.\n",block->number ); printBlock ( block ); #endif if (81 != block->number){ #if defined DEBUG printf ( "Need to make decision.\n" ); #endif return SUDOKU_DE; } #if defined DEBUG printf ("FindSubset() ended.\n"); #endif return SUDOKU_OK; }
//Read number List* readNumber() { #if defined DEBUG printf ("Enter readNumber().\n"); #endif int i,j; int ret = 0; int flag = 0; List* node = NULL; //Creat LIST try { node = new List; } catch ( ... ) { printf ("Initialize new LIST failed,return NULL point."); goto EXIT; } //Creat successful,initialize to 0 node->prior = NULL; memset( &(node->block),0x00,sizeof(SuDoku_block)); //initialize sudoku block while ( 0 == flag ) { printf ("Please enter sudoku number 9*9.\n"); for (i=0;i<9;i++) { printf ("Please enter 9 numbers in line %d.\n",i+1); for (j=0;j<9;j++) { scanf ("%d",&(node->block.point[i][j][0])); } } printf ("Confirm input.ReType:0, Type_OK:1, Exit:2.\n"); scanf ("%d",&flag); #if defined DEBUG printf ("Flag is %d.\n",flag); #endif }//end while //Don't want to continue if ( 2 == flag ) { memset( &(node->block),0x00,sizeof(SuDoku_block)); delete node; node = NULL; goto EXIT; } #if defined DEBUG printBlock ( &(node->block) ); #endif ret = gettimeofday( ¤tTime, NULL ); if (-1 == ret){ printf ("Call gettimeofday failed.\n"); goto EXIT; } /* #if defined DEBUG printf ("Sec is %u,Usec is %u.\n",currentTime.tv_sec, currentTime.tv_usec); #endif */ EXIT: #if defined DEBUG printf ("ReadNumber() ended.\n"); #endif return node; }
//Main function int main() { timeval newTime; int tmp_return = -1; int ret = 0; unsigned long runTime = 0; float second = 0; List* node = NULL; List* result = NULL; memset (&newTime,0x00,sizeof(newTime)); //Initialize puzzle node = readNumber(); if (NULL == node){ printf ("Exit to input.\n"); return SUDOKU_NG; } //Change form to binary tmp_return = doBinChange (&(node->block)); if ( SUDOKU_NG == tmp_return){ printf ("Error in binary change.\n"); return SUDOKU_NG; } //Find the minimum subset while (1) { if ( 0 == node->block.number ){ printf ("Error to find result.\n"); return SUDOKU_NG; } tmp_return = findSubset(&(node->block)); if ( SUDOKU_NG == tmp_return){ printf ("Error in findSubset change.\n"); return SUDOKU_NG; } else if ( SUDOKU_OK == tmp_return ){ // Finish calculate, break break; } else if ( SUDOKU_DE == tmp_return ){ //Make decision result = makeDecision (node); if ( NULL == result){ printf ("Error in decision.\n"); return SUDOKU_NG; } node = result; result = NULL; } else if ( SUDOKU_RE == tmp_return ){ //Regress result = regress(node); if ( NULL == result){ printf ("Error in regress.\n"); return SUDOKU_NG; } node = result; result = NULL; } else { printf ("Error in findSubset change.\n"); return SUDOKU_NG; } } //change form to decimal doDecChange(&(node->block)); ret = gettimeofday( &newTime, NULL ); if (-1 == ret){ printf ("Call gettimeofday failed.\n"); } else { /* #if defined DEBUG printf ("Finished!Now sec is %u,Usec is %u.\n", newTime.tv_sec,newTime.tv_usec); #endif */ runTime = (newTime.tv_sec - currentTime.tv_sec)*1000000 + newTime.tv_usec - currentTime.tv_usec; second = runTime/1000000.0; printf ("Run time is %f second.\n",second); } //print result printBlock(&(node->block)); return SUDOKU_OK; }