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 ...
随机推荐
- 刀哥多线程现操作gcd-10-delay
延迟操作 // MARK: - 延迟执行 - (void)delay { /** 从现在开始,经过多少纳秒,由"队列"调度异步执行 block 中的代码 参数 1. when 从现 ...
- bootstrap插件之Carousel
兼容:ie9以上 特点:滑动图片看起来永远只有两帧,过度完美:是html css js的完美配合:其中html的data属性起了关键性作用 前提:normalize.css jquery.js ht ...
- IBM MQ扩大队列最大消息长度
要设置MQ的最大消息长度,需要考虑同时设置队列管理,队列以及通道的最大消息长度. 具体操作如下: runmqsc 队列管理器名称 alter qmgr maxmsgl(10000000) 1 : al ...
- c++基础(一):数据类型和结构
1.map map<int, int> rankDict;//定义map rankDict[1] = 5; rankDict[2] = 6;//map赋值 int dictSize = r ...
- oc中对象的初始化
在.m文件中使用对象方法: - (id)init { _name =@"zhangsan"; _age = 18; return self; } 然后通过main方法中进行创建对象 ...
- MVC4.0 利用IActionFilter实现简单的后台操作日志功能
首先我们要了解MVC提供了4种常用的拦截器:IActionFilter(Action拦截器接口).IExceptionFilter(异常拦截器接口).IResultFilter(Result拦截器接口 ...
- bootstrap API地址
http://wenzhixin.net.cn/p/bootstrap-table/docs/examples.html#pagination-table
- 黑金开发板上开发的PWM
/*自己做的PWM程序*2014-01-09*/module pwm(clk,rst,led);input clk,rst;output [7:0] led;parameter T=31'd20000 ...
- UISlider swift
// // ViewController.swift // UILabelTest // // Created by mac on 15/6/23. // Copyright (c) 2015年 fa ...
- 消息点击事件的响应链---hitTest:withEvent:方法
*当用户点击屏幕时,会产生一个触摸事件,系统会将触摸事件加入到 UIApplication管理事件队里中 *UIApplication 会从事件队列中取出最前面的事件进行分发以便处理,通常,先发送事件 ...