首页 > 代码库 > 1298 The Hardest Problem Ever

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;}

 

1298 The Hardest Problem Ever