For a detailed explanation, see the analysis of another problem relative to it, the process here is her inverse process. Another question.
The code is as follows:
Class Solution {public:intTitletonumber (Strings) {String::reverse_iterator iter1, iter2; Iter1 =s. Rbegin (); Iter2 =s. rend ();intOutput =0; for(; Iter1! =s. rend (); iter1++) {if(*iter1==' Z ') {if(Output = =0) {*iter1=' 0 '; Output =1; }Else{*iter1=' A '; Output =1; }Continue; }if(*iter1==' Y ') {if(Output = =1) {*iter1=' 0 '; Output =1; }Else{output =0; }Continue; }if(Output = =1) {*iter1= (char) (*iter1+1); Output =0; } }intresult =0;intFactor =1; for(Iter1 =s. Rbegin (); Iter1! =s. rend (); iter1++) {if(*iter1!=' 0 ') {result = (*iter1- -) * factor + result; } factor = factor * -; }if(Output = =1Result = result + factor;returnResult }};
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Excel Sheet Column Number