void main() { int a[100]; int n; RandomArray(a,n); PrintArray(a,n); DisplayResult(a,n); getch(); }
main(){ //Values double A1, A2, B1, B2, C1, C2; //Display double X0,Y0,ANGLE; UserInstructions(); GetCoefficients(&A1, &A2, &B1, &B2, &C1, &C2); SolveIntersection(A1, A2, B1, B2, C1, C2, &X0, &Y0); SolveAngle(A1,A2,B1,B2,&ANGLE); DisplayResult(X0,Y0,ANGLE); }
int main() { DDRB = 2; PORTB = 2; USART_Init(__UBRR); sei(); //lcd_init(); uart_puts("BLABLA"); while(1) { uart_puts("BLABLA"); uint8_t error = Measure(&temp,&hum); //if (error == 0) DisplayResult(); _delay_ms(2000); //uart_putint(error,10); } }
// All files must have the main function. int main(int UNUSED(argc), char **UNUSED(argv)) { Result result; hid_t file_id; InitResult(&result); file_id = CreateTestFile(); if (file_id < 0) { printf("Fail to open temporary test file: %s\n", TEST_FILE); Clean(file_id); return EXIT_FAILURE; } CheckTestResult(TestRead(file_id), &result); Clean(file_id); DisplayResult(&result); return result.status; }
DWORD WINAPI computationThread_PC( LPVOID lpParam ){ // Buffer declarations long i ; long j ; for(;;){ GenerateTimeSample(); {//ComputeFFT init_inLoopPort_0(outLoopPort_0_inLo_0, 16/*init_size*/); trigger(); for(i = 0; i<8 ; i ++) {//cluster_0 char *outSub_i_out_clust_0 = &out_cluster_0_trig_0 [((i*(1))%8)]; sortData(dataOut_timeData, outLoopPort_0_inLo_0, outSub_i_out_clust_0, data1Out_data1In, data2Out_data2In, weights_W, 16/*size*/); for(j = 0; j<8 ; j ++) {//butterflyStep char *inSub_j_data1Out_d_0 = &data1Out_data1In_0 [((j*(1))%8)]; char *inSub_j_data2Out_d_0 = &data2Out_data2In_0 [((j*(1))%8)]; char *outSub_j_data1Out__0 = &data1Out_data1In [((j*(1))%8)]; char *outSub_j_data2Out__0 = &data2Out_data2In [((j*(1))%8)]; char *outSub_j_weights_W = &weights_W [((j*(1))%8)]; char *out_op2 = &res_in [((0*1)%1)]; char *out_op2_0 = &res_in [((0*1)%1)]; mult(outSub_j_data2Out__0, outSub_j_weights_W, res_in); add(outSub_j_data1Out__0, out_op2, inSub_j_data1Out_d_0); sub(outSub_j_data1Out__0, out_op2_0, inSub_j_data2Out_d_0); } collectData(data1Out_data1In_0, data2Out_data2In_0, dataOut_in, 16/*size*/); {//brSamples fftData_dataIn = &dataOut_in[0]; outLoopPort_0_inLo_0 = &dataOut_in[0]; } } } DisplayResult(); } return 0; }//computationThread
int main(int argc, char **argv) { l_int32 i, n, w, h, nactual, imax; BOX *box; BOXA *boxa; PIX *pixs, *pixd, *pix; PIXA *pixas, *pixat, *pixac; L_PTRA *papix, *pabox, *papix2, *pabox2; static char mainName[] = "ptra1_reg"; if (argc != 1) return ERROR_INT(" Syntax: ptra1_reg", mainName, 1); setLeptDebugOK(1); pixac = pixaCreate(0); if ((pixs = pixRead("lucasta.1.300.tif")) == NULL) return ERROR_INT("pixs not made", mainName, 1); pixGetDimensions(pixs, &w, &h, NULL); boxa = pixConnComp(pixs, &pixas, 8); pixDestroy(&pixs); boxaDestroy(&boxa); n = pixaGetCount(pixas); /* Fill ptras with clones and reconstruct */ fprintf(stderr, "Fill with clones and reconstruct\n"); MakePtrasFromPixa(pixas, &papix, &pabox, L_CLONE); pixat = ReconstructPixa(papix, pabox, CHOOSE_RECON); ptraDestroy(&papix, 0, 1); ptraDestroy(&pabox, 0, 1); DisplayResult(pixac, &pixat, w, h, 1); /* Remove every other one for the first half; * with compaction at each removal */ fprintf(stderr, "Remove every other in 1st half, with compaction\n"); MakePtrasFromPixa(pixas, &papix, &pabox, L_COPY); for (i = 0; i < n / 2; i++) { if (i % 2 == 0) { pix = (PIX *)ptraRemove(papix, i, L_COMPACTION); box = (BOX *)ptraRemove(pabox, i, L_COMPACTION); pixDestroy(&pix); boxDestroy(&box); } } pixat = ReconstructPixa(papix, pabox, CHOOSE_RECON); ptraDestroy(&papix, 0, 1); ptraDestroy(&pabox, 0, 1); DisplayResult(pixac, &pixat, w, h, 0); /* Remove every other one for the entire set, * but without compaction at each removal */ fprintf(stderr, "Remove every other in 1st half, without & then with compaction\n"); MakePtrasFromPixa(pixas, &papix, &pabox, L_COPY); for (i = 0; i < n; i++) { if (i % 2 == 0) { pix = (PIX *)ptraRemove(papix, i, L_NO_COMPACTION); box = (BOX *)ptraRemove(pabox, i, L_NO_COMPACTION); pixDestroy(&pix); boxDestroy(&box); } } ptraCompactArray(papix); /* now do the compaction */ ptraCompactArray(pabox); pixat = ReconstructPixa(papix, pabox, CHOOSE_RECON); ptraDestroy(&papix, 0, 1); ptraDestroy(&pabox, 0, 1); DisplayResult(pixac, &pixat, w, h, 0); /* Fill ptras using insert at head, and reconstruct */ fprintf(stderr, "Insert at head and reconstruct\n"); papix = ptraCreate(n); pabox = ptraCreate(n); for (i = 0; i < n; i++) { pix = pixaGetPix(pixas, i, L_CLONE); box = pixaGetBox(pixas, i, L_CLONE); ptraInsert(papix, 0, pix, L_MIN_DOWNSHIFT); ptraInsert(pabox, 0, box, L_FULL_DOWNSHIFT); } pixat = ReconstructPixa(papix, pabox, CHOOSE_RECON); ptraDestroy(&papix, 0, 1); ptraDestroy(&pabox, 0, 1); DisplayResult(pixac, &pixat, w, h, 1); /* Reverse the arrays by swapping */ fprintf(stderr, "Reverse by swapping\n"); MakePtrasFromPixa(pixas, &papix, &pabox, L_CLONE); for (i = 0; i < n / 2; i++) { ptraSwap(papix, i, n - i - 1); ptraSwap(pabox, i, n - i - 1); } ptraCompactArray(papix); /* already compact; shouldn't do anything */ ptraCompactArray(pabox); pixat = ReconstructPixa(papix, pabox, CHOOSE_RECON); ptraDestroy(&papix, 0, 1); ptraDestroy(&pabox, 0, 1); DisplayResult(pixac, &pixat, w, h, 0); /* Remove at the top of the array and push the hole to the end * by neighbor swapping (!). This is O(n^2), so it's not a * recommended way to copy a ptra. [joke] */ fprintf(stderr, "Remove at top, pushing hole to end by swapping -- O(n^2)\n"); MakePtrasFromPixa(pixas, &papix, &pabox, L_CLONE); papix2 = ptraCreate(0); pabox2 = ptraCreate(0); while (1) { ptraGetActualCount(papix, &nactual); if (nactual == 0) break; ptraGetMaxIndex(papix, &imax); pix = (PIX *)ptraRemove(papix, 0, L_NO_COMPACTION); box = (BOX *)ptraRemove(pabox, 0, L_NO_COMPACTION); ptraAdd(papix2, pix); ptraAdd(pabox2, box); for (i = 1; i <= imax; i++) { ptraSwap(papix, i - 1, i); ptraSwap(pabox, i - 1, i); } } ptraCompactArray(papix); /* should be empty */ ptraCompactArray(pabox); /* ditto */ pixat = ReconstructPixa(papix, pabox, CHOOSE_RECON); ptraDestroy(&papix, 0, 1); ptraDestroy(&pabox, 0, 1); DisplayResult(pixac, &pixat, w, h, 1); /* nothing there */ pixat = ReconstructPixa(papix2, pabox2, CHOOSE_RECON); ptraDestroy(&papix2, 0, 1); ptraDestroy(&pabox2, 0, 1); DisplayResult(pixac, &pixat, w, h, 0); /* Remove and insert one position above, allowing minimum downshift. * If you specify L_AUTO_DOWNSHIFT, because there is only 1 hole, * it will do a full downshift at each insert. This is a * situation where the heuristic (expected number of holes) * fails to do the optimal thing. */ fprintf(stderr, "Remove and insert one position above (min downshift)\n"); MakePtrasFromPixa(pixas, &papix, &pabox, L_CLONE); for (i = 1; i < n; i++) { pix = (PIX *)ptraRemove(papix, i, L_NO_COMPACTION); box = (BOX *)ptraRemove(pabox, i, L_NO_COMPACTION); ptraInsert(papix, i - 1, pix, L_MIN_DOWNSHIFT); ptraInsert(pabox, i - 1, box, L_MIN_DOWNSHIFT); } pixat = ReconstructPixa(papix, pabox, CHOOSE_RECON); ptraDestroy(&papix, 0, 1); ptraDestroy(&pabox, 0, 1); DisplayResult(pixac, &pixat, w, h, 1); /* Remove and insert one position above, but this time * forcing a full downshift at each step. */ fprintf(stderr, "Remove and insert one position above (full downshift)\n"); MakePtrasFromPixa(pixas, &papix, &pabox, L_CLONE); for (i = 1; i < n; i++) { pix = (PIX *)ptraRemove(papix, i, L_NO_COMPACTION); box = (BOX *)ptraRemove(pabox, i, L_NO_COMPACTION); ptraInsert(papix, i - 1, pix, L_AUTO_DOWNSHIFT); ptraInsert(pabox, i - 1, box, L_AUTO_DOWNSHIFT); } /* ptraCompactArray(papix); ptraCompactArray(pabox); */ pixat = ReconstructPixa(papix, pabox, CHOOSE_RECON); ptraDestroy(&papix, 0, 1); ptraDestroy(&pabox, 0, 1); DisplayResult(pixac, &pixat, w, h, 0); pixd = pixaDisplay(pixac, 0, 0); pixDisplay(pixd, 100, 100); pixWrite("/tmp/junkptra1.png", pixd, IFF_PNG); pixDestroy(&pixd); pixaDestroy(&pixac); pixaDestroy(&pixas); return 0; }
unsigned __stdcall ThinkThread( LPVOID _p ){ /************************************************************** 思考ルーチンを呼び出すスレッド **************************************************************/ int ret = 0; THINK_INFO info; MOVE* pmove = (MOVE*)_p; MOVE move; MMRESULT tid; int num; int msec_mate = 0; memset( &info, 0, sizeof(THINK_INFO) ); // 定跡を調べる。 if( pbook != NULL ){ ret = pbook->GetMove( pshogi, move ); if( ret != 0 ){ // 定跡の表示 moves.Init(); num = pbook->GetMoveAll( pshogi, moves ); DisplayBook( num, moves ); } } if( ret == 0 ){ // 詰み探索 sikou_flag = 1; // タイマーオン if( limit > 0 ){ // 詰みを調べる時間(最大1秒) msec_mate = limit * 1000 / 10; if( msec_mate > 1000 ){ msec_mate = 1000; } tid = timeSetEvent( msec_mate, 10, timelimit2, 0, TIME_ONESHOT ); } ret = pthink->DfPnSearch( pshogi, &move, NULL, &info, &chudanDfPn ); // タイマーオフ if( limit > 0 ){ timeKillEvent( tid ); } if( ret ){ DisplayResult( &info ); AddProgress( pshogi->GetStrMove( move ).c_str() ); } } if( ret == 0 ){ // 通常探索 sikou_flag = 1; // タイマーオン if( limit > 0 ){ tid = timeSetEvent( limit * 1000 - msec_mate, 10, timelimit, 0, TIME_ONESHOT ); } // 反復深化探索 ret = pthink->Search( pshogi, &move, 32, &info, &chudan, 1 ); // タイマーオフ if( limit > 0 ){ timeKillEvent( tid ); } DisplayResult( &info ); // 投了 if( ret != 0 && presign->bad( info ) ){ ret = 0; } } sikou_flag = 0; if( ret == 0 ) // 指し手がない return (DWORD)0; *(pmove) = move; return (DWORD)1; }