Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
让switch或者elseif快些的办法//字母连续的3个为一组,仅从'Q'以后错位一个,所以........ inline size_t parse(const string& raw) { size_t result(0); size_t len = raw.length(); char one_char; for(size_t i=0; i<len; ++i){ one_char = raw[i]; if (one_char > 'Q'){ result = result * 10 + (one_char-'B')/3 + 2; } else if (one_char >= 'A'){ result = result * 10 + (one_char-'A')/3 + 2; } else if (one_char >= '0') result = result * 10 + one_char - '0'; } return result; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator