水的问题。直接附着到代码。

//poj 2041
//sep9
#include <iostream>
using namespace std;
char mode[128];
char ori[128],res[128];
int len;
void J()
{
ori[0]=res[len-1];
for(int i=1;i<len;++i)
ori[i]=res[i-1];
}
void C()
{
ori[len-1]=res[0];
for(int i=0;i<len-1;++i)
ori[i]=res[i+1];
}
void E()
{
int i;
for(i=0;i<len/2;++i)
ori[i]=res[i+(len+1)/2];
if(len%2==1)
ori[len/2]=res[len/2];
for(i=(len+1)/2;i<len;++i)
ori[i]=res[i-(len+1)/2];
}
void A()
{
for(int i=0;i<len;++i)
ori[i]=res[len-1-i];
}
void P()
{
for(int i=0;i<len;++i)
if(res[i]<='9'&&res[i]>='0')
ori[i]=res[i]=='0'? '9':res[i]-1;
else
ori[i]=res[i];
}
void M()
{
for(int i=0;i<len;++i)
if(res[i]<='9'&&res[i]>='0')
ori[i]=res[i]=='9'?'0':res[i]+1;
else
ori[i]=res[i];
}
int main()
{
int i,n;
scanf("%d",&n);
while(n--){
scanf("%s%s",mode,res);
len=strlen(res);
ori[len]='\0';
for(i=strlen(mode)-1;i>=0;--i){
if(mode[i]=='J')
J();
else if(mode[i]=='C')
C();
else if(mode[i]=='E')
E();
else if(mode[i]=='A')
A();
else if(mode[i]=='P')
P();
else if(mode[i]=='M')
M();
strcpy(res,ori);
}
printf("%s\n",res);
}
return 0;
}

poj 2041 Unreliable Message 字符串处理的更多相关文章

  1. POJ 2041 Unreliable Message

    简单模拟.依照题意处理一下字符串就可以. 应该是写题号写错了,本来我在VirtualJudge是加入的POJ 并查集与生成树的题. #include<cstdio> #include< ...

  2. POJ 1035 Spell checker 字符串 难度:0

    题目 http://poj.org/problem?id=1035 题意 字典匹配,单词表共有1e4个单词,单词长度小于15,需要对最多50个单词进行匹配.在匹配时,如果直接匹配可以找到待匹配串,则直 ...

  3. POJ 1200 Crazy Search(字符串简单的hash)

    题目:http://poj.org/problem?id=1200 最近看了一个关于hash的问题,不是很明白,于是乎就找了些关于这方面的题目,这道题是一道简单的hash 字符串题目,就先从他入手吧. ...

  4. poj 1146 ID Codes (字符串处理 生成排列组合 生成当前串的下一个字典序排列 【*模板】 )

    ID Codes Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 6229   Accepted: 3737 Descript ...

  5. POJ 3080 Blue Jeans (字符串处理暴力枚举)

    Blue Jeans  Time Limit: 1000MS        Memory Limit: 65536K Total Submissions: 21078        Accepted: ...

  6. poj 2752 求一个字符串所有的相同前后缀

    求一个字符串所有的相同前后缀Sample Input ababcababababcababaaaaaSample Output 2 4 9 181 2 3 4 5 #include <iostr ...

  7. POJ2274 Long Long Message 字符串

    正解:SA/哈希+二分 解题报告: 传送门! 啊先放下翻译,,,?大意就有两个字符串,求这两个字符串的最长公共子串 先港SA的做法趴 就把两个子串拼接起来,然后题目就变成了求后缀的最长公共前缀了 所以 ...

  8. node.js 监听message事件 message字符串丢失信息

    const dgram = require("dgram"); const server = dgram.createSocket("udp4"); serve ...

  9. poj 1035 Spell checker ( 字符串处理 )

    Spell checker Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 16675   Accepted: 6087 De ...

随机推荐

  1. 实现C++模板类头文件和实现文件分离的方法

    如何实现C++模板类头文件和实现文件分离,这个问题和编译器有关. 引用<<C++primer(第四版)>>里的观点:1)标准C++为编译模板代码定义了两种模型:“包含”模型和“ ...

  2. USB HID Report Descriptor 报告描述符详解

    Report descriptors are composed of pieces of information. Each piece of information is called an Ite ...

  3. oracle 配置服务端

    oracle 配置服务端,类似我们配置java环境一样 防止乱码的配置: 变量名:NLS_LANG 变量值:SIMPLIFIED CHINESE_CHINA.ZHS16GBK 选择数据库的配置(重要) ...

  4. Tooltip(提示框)组件

    一.加载方式 //class加载方式 <a href="http://www.ycku.com" title="这是一个提示信息!" class=&quo ...

  5. .net程序开发人员必看的变量的命名规则

    (1)类名.属性名.方法名采用Pascal命名,如 class User { } interface IEditable { } bool ValidateInput() public int Age ...

  6. Head First HTML与CSS — 为你的页面加图像

    HTML中我们用img标签插入图像,在Web中常用的有三种:JPEG, PNG,GIF. 简单来讲,JPEG适合照片和复杂图像使用,而PNG或GIF适合单色图像.logo.和几何图形使用. JPEG: ...

  7. a标签调用js的几种方法

    我们常用的在a标签中有点击事件: <a> 标签的 href 属性用于指定超链接目标的 URL,href 属性的值可以是任何有效文档的相对或绝对 URL,包括片段标识符和 JavaScrip ...

  8. Asp.net - The type or namespace name 'App_Code' does not exist in the namespace 'xxx' (are you missing an assembly reference?)

    我在 项目 下面创建一个 App_Code的文件夹,然后在其下创建自定义的类,但是当我在该项目下别的地方使用时报错: The type or namespace name 'App_Code' doe ...

  9. IE6~9的css hack写法

    _color: red; /* ie6 */ *color: red; /* ie6/7 */ +color: red; /* ie6/7 */ color: red\0; /* ie8/9 */ c ...

  10. centos上安装rabbitmq并且python测试

    把我的阿里云重置了一下,重新安装rabbitmq,看看会出现什么问题. 首先,把erlang环境安装一下,直接 yum list | grep erlang erlang.x86_64 R16B-03 ...