string countAndSay(int n) { // Note: The Solution object is instantiated only once and is reused by each test case. if (n <= 0) return string(); string say = "1"; for (int i = 1; i < n; i++){ say = strConvert(say); } return say; }
void Game::Update() { while (1) { int receivedBytes = Socket.RecvFrom(bufff, sizeof(js_event)); if (receivedBytes == -1)return; memcpy(&e, bufff, sizeof(js_event)); string save; //wstring wsave = to_wstring(e.number) + L" " + to_wstring(e.time) + L" " + to_wstring(e.type) + L" " + to_wstring(e.value); //string save = to_string(e.number) + " " + to_string(e.time) + " " + to_string(e.type) + " " + to_string(e.value); if (e.type == 0x01) { if (e.value == 0)B_SET = 0; else B_SET = 1; switch (e.number) { case 0: save += "X,"; if (debug)AddString(L"Button 1"); if (flagX == 1) if (B_SET == 0) { countX++; flagX = 0; } B_2 = B_SET; if (B_SET == 1)flagX = 1; break; case 1: save += "A,"; if (debug)AddString(L"Button 2"); if (flagA == 1) if (B_SET == 0) { countA++; flagA = 0; } B_3 = B_SET; if (B_SET == 1)flagA = 1; break; case 2: save += "B,"; if (debug)AddString(L"Button 3"); if (flagB == 1) if (B_SET == 0) { countB++; flagB = 0; } B_4 = B_SET; if (B_SET == 1)flagB = 1; break; case 3: save += "Y,"; if (debug)AddString(L"Button 4"); if (flagY == 1) if (B_SET == 0) { countY++; flagY = 0; } B_1 = B_SET; if (B_SET == 1)flagY = 1; break; case 4: save += "L1,"; if (flagL == 1) if (B_SET == 0) { countL++; flagL = 0; } if (debug)AddString(L"L1"); B_L1 = B_SET; if (B_SET == 1)flagL = 1; break; case 5: save += "R1,"; if (flagR == 1) if (B_SET == 0) { countR++; flagR = 0; } if (debug)AddString(L"R1"); B_R1 = B_SET; if (B_SET == 1)flagR = 1; break; case 6: save += "L2,"; if (debug)AddString(L"L2"); B_L2 = B_SET; break; case 7: save += "R2,"; if (debug)AddString(L"R2"); B_R2 = B_SET; break; case 8: save += "Select,"; if (debug)AddString(L"Select"); if (flagSelect == 1) if (B_SET == 0) { NextSection(); flagSelect = 0; } B_9 = B_SET; if (B_SET == 1)flagSelect = 1; break; case 9: save += "Start,"; if (debug)AddString(L"Start"); B_10 = B_SET; break; case 10: save += "L3,"; if (debug)AddString(L"L3"); B_L3 = B_SET; break; case 11: save += "R3,"; if (debug)AddString(L"R3"); B_R3 = B_SET; break; } if (e.value == 0)save += "released,"; else save += "pressed,"; } else if (e.type == 0x02) { switch (e.number) { case 0: save += "LX,"; save += to_string(e.value) + ","; if (strDebug)AddString(L"Left X-Axis:"); B_LX = e.value; if (e.value == 0) { B_LEFT = 0; B_RIGHT = 0; } if (e.value == -32767)B_LEFT = 1; if (e.value == 32767)B_RIGHT = 1; break; case 1: save += "LY,"; save += to_string(e.value) + ","; if (strDebug)AddString(L"Left Y-Axis:"); B_LY = e.value; if (e.value == 0) { B_UP = 0; B_DOWN = 0; } if (e.value == -32767)B_UP = 1; if (e.value == 32767)B_DOWN = 1; break; case 2: save += "RX,"; save += to_string(e.value) + ","; if (strDebug)AddString(L"Right X-Axis:"); B_RX = e.value; break; case 3: save += "RY,"; save += to_string(e.value) + ","; if (strDebug)AddString(L"Right Y-Axis:"); B_RY = e.value; break; } if (e.value == 0)if (strDebug); if (strDebug)AddString(L"at Time:"); } else if (e.type == 0x80) { } save += to_string(e.time); wstring wsave; strConvert(wsave, save); if (prevStr != save) { SaveString(save); AddString(wsave); } prevStr = save; } }