__int64 Problem22::getValue(std::string str){ __int64 result = 0; for(int i=0;i<str.size();i++){ result += getCharValue(str[i]); } return result; }
void InputRecordRead(sFILE *fp) { gInput[INP_CH0].record = FALSE; gInput[INP_CH0].playback = FALSE; u_int header; FsRead(fp, &header, sizeof(u_int)); record_num = ntohl(header); record_ofs = record_num; FreeWork(record); record = (sInputRecord *)fsMalloc(sizeof(sInputRecord) * record_num, "record"); ASSERT(record); FileBuffer buffer; size_t size = FsGetSize(fp) - 4; void *zptr = fsMalloc(size, "zlib"); ASSERT(zptr); FsRead(fp, zptr, size); buffer.ptr = (u_char *)ZlibDecode(zptr, ZlibEncodeSize(zptr)); buffer.ofs = 0; Free(zptr); sInputRecord *ptr = record; for(int i = 0; i < record_ofs; i += 1) { ptr->x = (int)getIntValue(&buffer); ptr->y = (int)getIntValue(&buffer); ptr->btn_p = getIntValue(&buffer); ptr->btn_td = getIntValue(&buffer); ptr->btn_tu = getIntValue(&buffer); RecKey *recKey = ptr->recKey; for(int h = 0; h < KEY_INPUT_BUFFER * 2; h += 1) { recKey->key = getCharValue(&buffer); recKey->push = (BOOL)getCharValue(&buffer); recKey += 1; } ptr->recNum = getIntValue(&buffer); ptr += 1; } Free(buffer.ptr); }
double strToValue(string s){ int loc = s.find_first_not_of(decemalChar); string subs = s.substr(0, loc); double ret = atof(subs.c_str()); if(loc != string::npos){ char nota = s.at(loc); double suffix = getCharValue(nota); ret = ret * suffix; } return ret; }
/** * Donde char genes[] = {'A','C','G','T'}; A->0 C->1 G->2 T->3 */ int getValueOfMatch(char a, char b) { return SIMILARITY_MATRIX[getCharValue(a)][getCharValue(b)]; }