POJ 2041
#include <iostream>
#include <string>
#include <algorithm>
using namespace std; string fun_c(string s);
string fun_j(string s);
string fun_e(string s);
string fun_a(string s);
string fun_p(string s);
string fun_m(string s); int main()
{
//freopen("acm.acm","r",stdin);
int n;
string op;
string s;
int i;
cin>>n;
while(n --)
{
cin>>op;
cin>>s;
//cout<<op<<endl;
for(i = op.length()-; i >= ; -- i)
{
if(op[i] == 'A')
{
s = fun_a(s);
}
else if(op[i] == 'C')
{
s = fun_c(s);
}
else if(op[i] == 'J')
{
s = fun_j(s);
}
else if(op[i] == 'M')
{
s = fun_m(s);
}
else if(op[i] == 'P')
{
s = fun_p(s);
}
else if(op[i] == 'E')
{
s = fun_e(s);
} }
cout<<s<<endl;
}
} string fun_j(string s)
{
char tem;
int i;
// cout<<" 000000 "<<s.length()<<endl;
tem = s[s.length()-];
for(i = s.length()-; i > ; -- i)
{
s[i] = s[i-];
}
s[] = tem;
return s;
} string fun_c(string s)
{
int i;
char tem;
tem = s[];
for(i = ; i < s.length()-; ++ i)
{
s[i] = s[i+];
}
s[s.length()-] = tem;
return s;
} string fun_e(string s)
{
// cout<<"s :"<<s<<endl;
int len_half;
len_half = s.length()/;
string s_pre;
string s_bac;
int len_half_1;
int i;
// cout<<s.length()<<endl;
// cout<<"len "<<endl;
for(i = ; i < len_half; ++ i)
{
s_pre += s[i];
}
len_half_1 = s.length()-len_half;
for(i = len_half_1; i < s.length(); ++ i)
{
s_bac += s[i];
} for(i = ; i < len_half; ++ i)
{
s[i] = s_bac[i];
}
// cout<<len_half<<endl;
// cout<<len_half_1<<endl;
// cout<<")))))))))))))))"<<endl;
int j = ;
for(i = len_half_1; i < s.length(); ++ i)
{
s[i] = s_pre[j ++];
} // cout<<"p :"<<s_pre<<endl;
// cout<<"b :"<<s_bac<<endl;
return s;
} string fun_a(string s)
{
reverse(s.begin(),s.end());
return s;
} string fun_p(string s)
{
int i;
for(i = ; i < s.length(); ++ i)
{
if(s[i] >= '' && s[i] <= '')
{
s[i] = char(s[i]-);
}
else if(s[i] == '')
{
s[i] = '';
}
}
return s;
} string fun_m(string s)
{
int i;
for(i = ; i < s.length(); ++ i)
{
if(s[i] >= '' && s[i] <= '')
{
s[i] = char(s[i]+);
}
else if(s[i] == '')
{
s[i] = '';
}
}
return s;
}
关注我的公众号,当然,如果你对Java, Scala, Python等技术经验,以及编程日记,感兴趣的话。

技术网站地址: vmfor.com
POJ 2041的更多相关文章
- poj 2041 Unreliable Message 字符串处理
水的问题.直接附着到代码. //poj 2041 //sep9 #include <iostream> using namespace std; char mode[128]; char ...
- POJ 2041 Unreliable Message
简单模拟.依照题意处理一下字符串就可以. 应该是写题号写错了,本来我在VirtualJudge是加入的POJ 并查集与生成树的题. #include<cstdio> #include< ...
- poj 题目分类(1)
poj 题目分类 按照ac的代码长度分类(主要参考最短代码和自己写的代码) 短代码:0.01K--0.50K:中短代码:0.51K--1.00K:中等代码量:1.01K--2.00K:长代码:2.01 ...
- POJ题目分类(按初级\中级\高级等分类,有助于大家根据个人情况学习)
本文来自:http://www.cppblog.com/snowshine09/archive/2011/08/02/152272.spx 多版本的POJ分类 流传最广的一种分类: 初期: 一.基本算 ...
- OpenJudge / Poj 1044 Date bugs C++
链接地址: Poj:http://poj.org/problem?id=1044 OpenJudge:http://bailian.openjudge.cn/practice/1044/ 题目: 总时 ...
- POJ题目细究
acm之pku题目分类 对ACM有兴趣的同学们可以看看 DP: 1011 NTA 简单题 1013 Great Equipment 简单题 102 ...
- 转载:poj题目分类(侵删)
转载:from: POJ:http://blog.csdn.net/qq_28236309/article/details/47818407 按照ac的代码长度分类(主要参考最短代码和自己写的代码) ...
- POJ 3370. Halloween treats 抽屉原理 / 鸽巢原理
Halloween treats Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 7644 Accepted: 2798 ...
- POJ 2356. Find a multiple 抽屉原理 / 鸽巢原理
Find a multiple Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 7192 Accepted: 3138 ...
随机推荐
- 线程操作API
线程操作API 1.currentThread 2.getId() .getName().getPriority().getStart.isAlive().isDaemon().isInterrupt ...
- Oracle结果集 (MSSQL存储过程写报表)
接触SQL Server比较多,写报表是用存储过程实现. 对Oracle实现像MSSQL那样,还是有很多疑问
- EXCLE使用宏生成目录
宏代码: Sub mu() Dim i As Integer Dim ShtCount As Integer Dim SelectionCell As Range ShtCount = Workshe ...
- [译]rabbitmq 2.5 Where’s my message? Durability and you
我对rabbitmq学习还不深入,这些翻译仅仅做资料保存,希望不要误导大家. There’s a dirty secret about creating queues and exchanges in ...
- Hadoop组成
Hadoop由以下几个子项目组成: Hadoop Common Hadoop体系最底层的一个模块,为Hadoop各子项目提供各种工具,如:配置文件和日志操作等. Avro Avro是doug cutt ...
- xcode 产生指定颜色的图片imageWithColor
是在万能的stackOverflow上找到的答案,留下了, 原地址:http://stackoverflow.com/questions/6496441/creating-a-uiimage-from ...
- (转)android Fragments详解三:实现Fragment的界面
为fragment添加用户界面 fragment一般作为activity的用户界面的一部分,把它自己的layout嵌入到activity的layout中. 一个 要为fragment提供layo ...
- Rstdio中更换R版本
1.打开Rstdio,选择Tool --> Global Options.
- Matlab实现加性高斯白噪声信道(AWGN)下的digital调制格式识别分类
Matlab实现加性高斯白噪声信道(AWGN)下的digital调制格式识别分类 内容大纲 加性高斯白噪声信道(AWGN)下的digital调制格式识别分类 (1. PSK; 2. QPSK; 3.8 ...
- ASP.NET Web API 入门大杂烩
[前言] 本文是大杂烩,意思即是:到处Copy再加一点点思考而混在一起的文章,引用来源因为太多太杂故而省略,望原作者原谅. [概述] ASP.NET Web API随ASP.NET MVC 4一起发行 ...