#include <cstdio> #include <iostream> using namespace std; int f[30], F[30]; int main() { char c; int n, m, p; cin >> n; for(int i = 1; i <= 26; ++ i) f[i] = -i; for(int i = 1; i <= 26; ++ i) F[i] = i; while(n --) { cin >> c >> m; if(c >= ‘a‘ && c <= ‘z‘) p = f[c - ‘a‘ + 1]; else if(c >= ‘A‘ && c <= ‘Z‘) p = F[c - ‘A‘ + 1]; printf("%d\n", m + p); } return 0; }
原文:https://www.cnblogs.com/mjn1/p/11298900.html