HttpMessageHeader *hmhInit() { HttpMessageHeader * hmh = malloc( sizeof( HttpMessageHeader ) ); if ( ! hmh ) { handle_error( "hmhInit" ); } memset( hmh, 0, sizeof( HttpMessageHeader ) ); hmh->fieldName = dsInit( 16 ); hmh->fieldValue = dsInit( 100 ); return hmh; }
void main() #endif { stdout=GetStdHandle(STD_OUTPUT_HANDLE); print("\nFarbrausch Tiny Music Player v0.dontcare TWO\n"); print("Code and Synthesizer (W) 2000-2008 kb/Farbrausch\n"); print("\n\nNow Playing: 'Patient Zero' by Melwyn & Little Bitchard\n"); player.Init(); player.Open(theTune); dsInit(player.RenderProxy,&player,GetForegroundWindow()); player.Play(); sInt startTicks = GetTickCount(); print("\n\npress ESC to quit\n"); while (GetAsyncKeyState(VK_ESCAPE)>=0) { Sleep(10); } dsClose(); player.Close(); //synthPrintCoverage(); ExitProcess(0); }
int main(void) { scanf("%d", &T); while (T--) { scanf("%d", &n); dsInit(n); for (i = 0; i < n; i++) { scanf("%d%d", &points[i].x, &points[i].y); } m = 0; for (i = 0; i < n - 1; i++) { for (j = i + 1; j < n; j++) { edges[m].v1 = i; edges[m].v2 = j; edges[m].weight = hypot(points[i].x - points[j].x, points[i].y - points[j].y); m++; } } qsort(edges, m, sizeof(edges[0]), cmp); totalweight = 0; cnt = n; for (i = 0; i < m; i++) { if (edges[i].weight >= 10 && edges[i].weight <= 1000 && join(edges[i].v1, edges[i].v2)) { totalweight += edges[i].weight; } } if (cnt > 1) { printf("oh!\n"); } else { printf("%.1lf\n", totalweight * 100); } } return EXIT_SUCCESS; }
int main(void) { while(scanf("%d", &n)!=EOF){ dsInit(n); m = 0; edgeN = n * (n - 1) / 2; for (i = 0; i < n; i++) { for (j = 0; j < n; j++) { scanf("%d", &k); if (j > i) { edges[m].v1 = i; edges[m].v2 = j; edges[m].weight = k; m++; } } } scanf("%d", &q); while (q--) { scanf("%d%d", &a, &b); join(a - 1, b - 1); } qsort(edges, edgeN, sizeof(edges[0]), cmp); totalweight = 0; for (i = 0; i < edgeN; i++) { if (join(edges[i].v1, edges[i].v2)) { totalweight += edges[i].weight; } } printf("%d\n", totalweight); } return EXIT_SUCCESS; }
DString* hmhToString( HttpMessageHeader* hmh, DString *dest ) { if ( !dest ) dest = dsInit( 100 ); dsCatF( dest, "%S: %S", hmh->fieldName, hmh->fieldValue ); return dest; }
void kragInit( int stereo ) { kramSetMasterVol( 128 ); dsInit( stereo ); kramResetChannels( 1 ); // needed if kragInit is called more than once, so stereo-channels are set to mono or vice versa kradActivate(); krapInit(); }
DString* hslToString( HttpStatusLine* hsl, DString *dest ) { if ( !dest ) dest = dsInit( 100 ); dsCatF( dest, "%s %d %s", httpVersionToString( hsl->httpversion ), (int) hsl->statuscode, hscReasonphrase( hsl->statuscode ) ); return dest; }
float dsReadT() { unsigned char temp1, temp2; unsigned int temp3; signed int temp4; float result; static unsigned char initFalg = 1; if ( initFalg ) { if ( dsInit() == 0 ) { initFalg = 0; } else { return ( -10000.0 ); } } oneWireReset(); if (oneWireCheck() == 1) return ( -10000.0 ); oneWireWrite(SKIP_ROM); oneWireWrite(CONVERT_T); /* The master can issue read time slots after the Convert T command and ** the DS18B20 will respond by transmitting a 0 while the temperature ** conversion is in progress and a 1 when the conversion is done. */ while (oneWireRead() == 0); //check the DS18B20 if busy? oneWireReset(); if (oneWireCheck() == 1) return ( -10000.0 ); oneWireWrite(SKIP_ROM); oneWireWrite(READ_REG); temp1 = oneWireRead(); // Temperature LSB(50h) temp2 = oneWireRead(); // Temperature MSB(05h) temp3 = (unsigned int)( (temp2 << 8) | temp1); if (temp2 & 0xF8) // 温度数据是否有符号位,若有则为负温度 temp4 = ((temp3^0x7FFF) + 0x0001); // 为负温度时,数据为补码,所以转换为负数的原码 else temp4 = (signed int)temp3; result = (float)(temp4 * 0.0625); // Calculation for DS18S20 with 0.0625 deg C resolution //result = (float)temp4 / 16.0; //result = (float)temp4 / 2.0; // Calculation for DS18S20 with 0.5 deg C resolution return result; }
// Return 0 for no error int WindowInit() { gs_WindowInfos.hInstance = GetModuleHandle( NULL ); #ifndef _WIN64 ////////////////////////////////////////////////////////////////////////// // Initialize rounding mode once since we disabled f*****g _ftol2 link error by adding a deprecated compile flag named /QIfist // (always following the advice from http://www.benshoof.org/blog/minicrt/) static U16 CW; __asm { fstcw CW // store fpu control word mov dx, word ptr [CW] or dx, 0x0C00 // rounding: truncate (default) mov CW, dx fldcw CW // load modfied control word } #endif ////////////////////////////////////////////////////////////////////////// // Register the new window class WNDCLASSA wc; memset( &wc, 0, sizeof(WNDCLASSA) ); wc.style = CS_OWNDC; wc.lpfnWndProc = WndProc; wc.hInstance = gs_WindowInfos.hInstance; wc.lpszClassName = pWindowClass; if( !RegisterClass( (WNDCLASSA*) &wc ) ) return ERR_REGISTER_CLASS; ////////////////////////////////////////////////////////////////////////// // Create the window U32 dwExStyle, dwStyle; if ( gs_WindowInfos.bFullscreen ) { if ( ChangeDisplaySettings( &ScreenSettings, CDS_FULLSCREEN ) != DISP_CHANGE_SUCCESSFUL ) return ERR_CHANGE_DISPLAY_SETTINGS; dwExStyle = WS_EX_APPWINDOW; dwStyle = WS_VISIBLE | WS_POPUP | WS_CLIPSIBLINGS | WS_CLIPCHILDREN; ShowCursor( 0 ); } else { dwExStyle = WS_EX_APPWINDOW;// | WS_EX_WINDOWEDGE; dwStyle = WS_VISIBLE | WS_CAPTION | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_SYSMENU; } RECT WindowRect; WindowRect.left = 0; WindowRect.top = 0; WindowRect.right = RESX; WindowRect.bottom = RESY; #ifdef ALLOW_WINDOWED AdjustWindowRect( &WindowRect, dwStyle, false ); gs_WindowInfos.hWnd = CreateWindowEx( dwExStyle, wc.lpszClassName, wc.lpszClassName, dwStyle, (GetSystemMetrics(SM_CXSCREEN)-WindowRect.right+WindowRect.left)>>1, (GetSystemMetrics(SM_CYSCREEN)-WindowRect.bottom+WindowRect.top)>>1, WindowRect.right-WindowRect.left, WindowRect.bottom-WindowRect.top, 0, 0, gs_WindowInfos.hInstance, 0 ); #else gs_WindowInfos.hWnd = CreateWindowEx( dwExStyle, wc.lpszClassName, wc.lpszClassName, dwStyle, 0, 0, WindowRect.right-WindowRect.left, WindowRect.bottom-WindowRect.top, 0, 0, gs_WindowInfos.hInstance, 0 ); #endif if( gs_WindowInfos.hWnd == NULL ) return ERR_CREATE_WINDOW; if( (gs_WindowInfos.hDC = GetDC( gs_WindowInfos.hWnd )) == NULL ) return ERR_RETRIEVE_DC; SetForegroundWindow( gs_WindowInfos.hWnd ); SetFocus( gs_WindowInfos.hWnd ); ////////////////////////////////////////////////////////////////////////// // Initialize DirectX Device // // Video Test( *((Device*) NULL), gs_WindowInfos.hWnd ); // gs_Device.Init( RESX, RESY, gs_WindowInfos.hWnd, gs_WindowInfos.bFullscreen, true ); if ( !gs_Device.IsInitialized() ) return ERR_DX_INIT_DEVICE; // Oopsy daisy shit f**k hell ! ////////////////////////////////////////////////////////////////////////// // Initialize sound player #ifdef MUSIC gs_Music.Init(); int WorkMemSize = synthGetSize(); gs_pMusicPlayerWorkMem = new U8[WorkMemSize]; U32 TuneSize = 0; const U8* pTheTune = LoadResourceBinary( IDR_MUSIC, "MUSIC", &TuneSize ); if ( pTheTune == NULL ) return ERR_MUSIC_RESOURCE_NOT_FOUND; if ( !gs_Music.Open( pTheTune ) ) return ERR_MUSIC_INIT; dsInit( gs_Music.RenderProxy, &gs_Music, gs_WindowInfos.hWnd ); // Readback positions // sS32* pPositions = NULL; // U32 PositionsCount = gs_Music.CalcPositions( &pPositions ); // delete[] pPositions; #endif ////////////////////////////////////////////////////////////////////////// // Initialize other static fields return 0; }