HDU 1982 Kaitou Kid - The Phantom Thief (1)

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;

}

 

你可能感兴趣的:(ant)