九度 1127

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

#ifdef ONLINE_JUDGE                                   
#define FINPUT(file)  0
#define FOUTPUT(file) 0
#else                                                
#define FINPUT(file)  freopen(file,"r",stdin)
#define FOUTPUT(file) freopen(file,"w",stdout)
#endif

void trans(string &s)
{
    for(int i=0;i<s.length();i++)
    {
        if(s[i]<='Z' && s[i]>='A' && s[i]-5<'A')
            s[i] = s[i] + 26 - 5;
        else if(s[i]<='Z'&&s[i]>='A')
            s[i] = s[i] - 5;
    }
}

int main()
{    
	FINPUT("in.txt");
    FOUTPUT("out.txt");

    string s1,s2,s3;
    while(getline(cin,s1))
    {   
        if(s1=="ENDOFINPUT")
            break;
        
        else if(s1=="START")
        {
            getline(cin,s2);
            trans(s2);
            cin>>s3;
            if(s3=="END")
                cout<<s2<<endl;
        }             
    }
    return 0;
}

你可能感兴趣的:(Algorithm,算法)