HDU 1048 The Hardest Problem Ever

题目地址:点击打开链接

思路:不用找规律,直接贴数组,数组开大点,否则会错

AC代码:

#include <iostream>
#include<cstring>

using namespace std;

int main()
{
    int n,i;
    char a[27] = "VWXYZABCDEFGHIJKLMNOPQRSTU";
    char cipher[1000];
    while(cin.getline(cipher,1000))
    {
        if(strcmp(cipher,"ENDOFINPUT") == 0)
            break;
        if(strcmp(cipher,"START") != 0 && strcmp(cipher,"END") != 0)
        {
            n = strlen(cipher);
            for(i=0; i<n; i++)
            {
                if(cipher[i] >= 'A' && cipher[i] <= 'Z')
                {
                    cout<<a[cipher[i] - 'A'];
                }
                else
                    cout<<cipher[i];
            }
            cout<<endl;
        }
    }
    return 0;
}


你可能感兴趣的:(HDU 1048 The Hardest Problem Ever)