http://acm.hdu.edu.cn/showproblem.php?pid=1982

字符串处理

View Code
#include <iostream>
#include <string>
using namespace std ;
char str[27]={"ABCDEFGHIJKLMNOPQRSTUVWXYZ"};
int main()
{
    int t;
    scanf("%d%*c",&t);
    while(t--)
    {
        string s;
        cin >> s ;
        for(int i=0;i<s.length();i++)
        {
            
            if(s[i]=='#'){
                putchar(' ');
                continue;
            }
            if(s[i]>='0'&&s[i]<='9')
            {
                int sum;
                sum=s[i]-'0';
                i++;
                if(!(s[i]>='0'&&s[i]<='9')){
                    putchar(str[sum-1]);
                    i--;
                    continue;
                }
                sum*=10;
                sum+=s[i]-'0';
                putchar(str[sum-1]);
            }
        }
        putchar('\n');
    }
    return 0;
}