// 思路是网上以一位大神的,特简单直接采用字符串,判断长度,还有最后一个元素是否T,便可通过ASCll输出数字;
#include <iostream> #include <string> using namespace std; string s; int main(){ while (cin >> s){ if (s.size() == 3 && s[2] == ‘T‘) cout << s[0] - ‘A‘ + 1; } cout << endl; return 0; }
原文:https://www.cnblogs.com/Hk456/p/10742789.html