1298 The Hardest Problem Ever

题目链接:http://poj.org/problem?id=1298

思路分析:水题,字符偏移求解,注意字符串输入问题即可。

 

代码如下:

#include <iostream>
#include <string>
using namespace std;

const int MAX_N = 200 + 10;
char A[MAX_N];

int main()
{
    int Len;
    char Tmp[20];

    while ( scanf( "%s", Tmp )!= EOF )
    {
        if( strcmp( Tmp, "ENDOFINPUT" ) == 0 )
            break;

        getchar( );
        gets( A );
        Len = strlen( A );
        for ( int i = 0; i < Len; ++i )
        {
            if ( A[i] >= 'A' && A[i] <= 'Z' )
                 A[i] = (( ( A[i]-'A') - 5 + 26 ) % 26) + 'A';
        }
        gets( Tmp );
        cout << A << endl;
    }

    return 0;
}
原文地址:https://www.cnblogs.com/tallisHe/p/4049228.html