int main( void ) { int i, l, r, c, n, res; for (i = 0; i <= 60; i++) D[i][0] = 10000; D[0][0] = 0; D[1][0] = 1; D[1][1] = 0; for (i = 2; i <= 60; i++) for (c = 0; c < i; c++) if (max(D[c][0], D[i - c - 1][0]) + 1 < D[i][0]) D[i][0] = max(D[c][0], D[i - c - 1][0]) + 1, D[i][1] = c; n = getN(); res = n + 1; l = 1, r = n; while (l <= r) { c = l + D[r - l + 1][1]; if (my_query(c)) res = c, r = c - 1; else l = c + 1; } answer(res); return 0; }
wyBool ImportBatch::GetCurDatabase() { wyInt32 ret; wyString query; MYSQL_RES* myres; MYSQL_ROW myrow; wyString myrowstr; MDIWindow *wnd = GetActiveWin(); wyBool ismysql41 = wnd->m_ismysql41; query.Sprintf("select database()"); wnd->SetThreadBusy(wyTrue); ret = my_query(wnd, m_tunnel, m_umysql, query.GetString(), query.GetLength()); wnd->SetThreadBusy(wyFalse); if(ret) { ShowMySQLError(m_hwnd, m_tunnel, m_umysql, query.GetString()); return wyFalse; } myres = m_tunnel->mysql_store_result(*m_umysql, false, false, GetActiveWin()); if(!myres) { ShowMySQLError(m_hwnd, m_tunnel, m_umysql, query.GetString()); return wyFalse; } myrow = m_tunnel->mysql_fetch_row(myres); if(myrow[0]) { myrowstr.SetAs(myrow[0], ismysql41); strncpy(m_curdb, myrowstr.GetString(), myrowstr.GetLength()); } else m_curdb[0] = NULL; if( strlen(m_curdb) == 0) strcpy(m_curdb, "<None>"); myrowstr.SetAs(m_curdb); SendMessage(GetDlgItem(m_hwnd, IDC_CURDATABASE), WM_SETTEXT, 0, (LPARAM)myrowstr.GetAsWideChar()); m_tunnel->mysql_free_result(myres); return wyTrue; }
//just for a test int main() { GameNode g1; g1.Gamename=2; g1.GameIntroduction=13; g1.CompanyIntroduction=12; g1.PlayingHours=20; GameNode g2; g2.Gamename=3; g1.GameIntroduction=4; g1.CompanyIntroduction=2; g1.PlayingHours=20; GameNode g3; g3.Gamename=1; g3.GameIntroduction=23; g3.CompanyIntroduction=2; g3.PlayingHours=20; GameNode g4; GameNode g5; GameListNode *head = malloc(sizeof(GameListNode)); head->prev=NULL; head->gamenode=g1; GameListNode *node2 = malloc(sizeof(GameListNode)); head->next=node2; node2->prev=head; node2->gamenode=g2; node2->next=NULL; printf("%d\n",my_insert(&head,g3)); GameListNode *current=head; while(current!=NULL) { printf("%d\n",(current->gamenode).Gamename); current=current->next; } printf("%d\n",my_remove(&head,3)); current=head; while(current!=NULL) { printf("%d\n",(current->gamenode).Gamename); current=current->next; } GameListNode * gn = my_query(head,1); if (gn!=NULL) printf("query%d\n",(gn->gamenode).GameIntroduction); int *test; int i; test= sortByKeyWord(head,1); for (i=0;i<2;i++) printf("%d\n",test[i]); return 0; }