int main() { try { vector<string> strElems; read_from_file(strElems, "p105_sets.txt"); ofstream output_file("output_file.txt"); vector<int> intElems; int result = 0; for (int i = 0; i < strElems.size(); ++i) { convert_to_int(strElems[i], intElems); sort(intElems.begin(), intElems.end()); SSS sss = SSS(intElems); if (sss.isSpecialSumSet()) { result += sss.sum(); output_file << strElems[i]; output_file << '\t'; output_file << sss.sum(); output_file << '\n'; } } cout << result << endl; } catch (exception) { cerr << "error with 'main'"; } }
template<bool isReader> void MDEC_SyncState(EW::NewState *ns) { NSS(ClockCounter); NSS(MDRPhase); SSS(InFIFO); SSS(OutFIFO); NSS(block_y); NSS(block_cb); NSS(block_cr); NSS(Control); NSS(Command); NSS(InCommand); NSS(QMatrix); NSS(QMIndex); NSS(IDCTMatrix); NSS(IDCTMIndex); NSS(QScale); NSS(Coeff); NSS(CoeffIndex); NSS(DecodeWB); NSS(PixelBuffer); NSS(PixelBufferReadOffset); NSS(PixelBufferCount32); NSS(InCounter); NSS(RAMOffsetY); NSS(RAMOffsetCounter); NSS(RAMOffsetWWS); }
// prints each series in the hash, also stores a pointer // for each series indexed by the order printed in eps_ptr static void print_menu(Eps** eps_ptr, Eps *hash ) { sqlite3 *db; int result; result = sqlite3_open(DATABASE, &db); if( result ) { efprintf("show_menu failed: %s\n", sqlite3_errmsg(db)); sqlite3_close(db); exit(23); } sqlite3_stmt *statement_h; const char *query_h = "select current from SeriesData where Title = ?"; sqlite3_prepare_v2(db, query_h, (int) strlen(query_h), &statement_h, NULL); int index =0; // Prints each series of a separate row for(Eps *e=hash; e != NULL; e=e->hh.next, ++index) { // uses a array indexing index to series then use that to select the right series eps_ptr[index] = e; bool ordered = true; qsort_b(e->eps->arr, e->eps->index, sizeof(size_t), ^(const void *a, const void *b){ const Ep *ea = *((Ep**)a), *eb = *((Ep**)b); mmprintf("%ld %ld res: %d\n", ea->num, eb->num, longcmp( ea->num, eb->num ) ); return longcmp( ea->num , eb->num ); } ); if (e->eps->index > 1){ for(int i = 0; i<e->eps->index-1;i++){ if (EPS_ARR(e,i+1)->num != 1 + EPS_ARR(e,i)->num){ ordered = false; break; } } } sqlite3_bind_text(statement_h, 1, e->series, -1, SQLITE_TRANSIENT); result = sqlite3_step(statement_h); mmprintf("r:%i Row:%i Ok:%i done:%i \n", result, SQLITE_ROW, SQLITE_OK, SQLITE_DONE ); int current =-1; if (result == SQLITE_ROW|| result == SQLITE_OK || result == SQLITE_DONE){ current = sqlite3_column_int(statement_h, 0); mmprintf("current:%d\n",current ); }else{ efprintf( "SQL error %s : %s\n", e->series, sqlite3_errmsg(db)); exit(12); } // Printing printf( SSS("%-2d") " :", COLOUR(index,GREEN)); printf(" P: " SSS("%-2d"), COLOUR(current,WHITE)); printf(" N: "); if (ordered && e->eps->index > 1 ){ // Range of eps printf(SSS("%4ld") SSS("-%-4ld"), COLOUR(EPS_ARR(e,0)->num, BLUE), COLOUR(EPS_ARR(e,e->eps->index-1)->num,BLUE) ); }else if (e->eps->index == 1){ // single ep const int extra = (3-1)*3; printf(SSS("%2ld") " %*s", COLOUR(EPS_ARR(e,0)->num, YELLOW), extra,"" ); }else{ // range with eps missing (only shows the fist three) const int min = e->eps->index < 3 ? e->eps->index :3; const int extra = (3-min)*3; for(int i = 0; i<min;i++){ printf(SSS("%2ld") " %*s", COLOUR(EPS_ARR(e,i)->num, RED), extra,"" ); } } printf(" %s\n", e->series); result = sqlite3_reset(statement_h); }