标签:
相似与27进制的转换
#include<iostream> #include<cstdio> #include<cstring> #include<string> #include<cstdlib> #include<algorithm> #include<stack> using namespace std; int main(){ int t; string s; cin>>t; while(t--) { cin>>s; if(s[0] >= ‘A‘) { int res = 0; int len = s.length(); for(int i=0; i<len; i++){ res = res*26+s[i]-‘A‘+1; } cout<<res<<endl; } else { string res; int n = atoi(s.c_str()); while(n){ if(n%26 == 0){ res += ‘Z‘; n -= 26; } else res += n%26+‘A‘-1; n /= 26; } reverse(res.begin(), res.end()); cout<<res<<endl; } } return 0; }
[河南省ACM省赛-第四届] 序号互换 (nyoj 303)
标签:
原文地址:http://www.cnblogs.com/vegg117/p/4385310.html