标签:算法
#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 convert(string &s) { for(int i=0;i<s.length();i++) { if((s[i]>=‘a‘&&s[i]<=‘z‘)) { s[i] = ‘z‘ - s[i] + ‘a‘; } else if((s[i]>=‘A‘&&s[i]<=‘Z‘)) s[i] = ‘Z‘ - s[i] + ‘A‘; } } int main() { FINPUT("in.txt"); FOUTPUT("out.txt"); string s; while(getline(cin,s)) { if(s=="!") break; convert(s); cout<<s<<endl; } return 0; }
标签:算法
原文地址:http://blog.csdn.net/daringpig/article/details/25490223