只需要对word遍历一遍即可
int write(string word) { int cnt = 0; for(int i = 0 ; i < word.length(); ++ i){ cnt+=word[i]-'A'+1; } return cnt; }
只需要对word遍历一遍即可
int write(string word) { int cnt = 0; for(int i = 0 ; i < word.length(); ++ i){ cnt+=word[i]-'A'+1; } return cnt; }
转载于:https://www.cnblogs.com/xiongqiangcs/p/3791572.html