POJ 2041 Unreliable Message
简单模拟。依照题意处理一下字符串就可以。
应该是写题号写错了,本来我在VirtualJudge是加入的POJ 并查集与生成树的题。
#include<cstdio>
#include<cstring>
#include<string>
#include<queue>
#include<algorithm>
#include<queue>
#include<map>
#include<stack>
#include<iostream>
#include<list>
#include<set>
#include<cmath>
#define INF 0x7fffffff
#define eps 1e-6
using namespace std;
void Mr_j(char *str)
{
int len=strlen(str);
char tmp=str[len-1];
for(int i=len-1;i>=0;i--)
str[i]=str[i-1];
str[0]=tmp;
}
void Mr_c(char *str)
{
int i;
char tmp=str[0];
for(i=0;i<strlen(str)-1;i++)
str[i]=str[i+1];
str[i]=tmp;
}
void Mr_e(char *str)
{
int len=strlen(str);
int i,j;
char tmp[1001];
for(i=0;i<len/2;i++)
tmp[i]=str[i];
if(len&1)i++;
for(j=0;i<len;i++,j++)
str[j]=str[i],str[i]=tmp[j];
}
void Mr_a(char *str)
{
int len=strlen(str);
for(int i=0;i<len/2;i++)
swap(str[i],str[len-i-1]);
}
void Mr_p(char *str)
{
for(int i=0;i<strlen(str);i++)
{
if(str[i]>'0'&&str[i]<='9')str[i]--;
else if(str[i]=='0')str[i]='9';
}
}
void Mr_m(char *str)
{
for(int i=0;i<strlen(str);i++)
{
if(str[i]>='0'&&str[i]<'9')str[i]++;
else if(str[i]=='9')str[i]='0';
}
}
int main()
{
char str[1001];
char order[1001];
int m;
scanf("%d",&m);
while(m--)
{
scanf("%s%s",order,str);
for(int i=strlen(order)-1;i>=0;i--)
{
if(order[i]=='J')Mr_j(str);
else if(order[i]=='C')Mr_c(str);
else if(order[i]=='E')Mr_e(str);
else if(order[i]=='A')Mr_a(str);
else if(order[i]=='P')Mr_p(str);
else if(order[i]=='M')Mr_m(str);
}
puts(str);
}
}
POJ 2041 Unreliable Message的更多相关文章
- poj 2041 Unreliable Message 字符串处理
水的问题.直接附着到代码. //poj 2041 //sep9 #include <iostream> using namespace std; char mode[128]; char ...
- POJ 2041
#include <iostream> #include <string> #include <algorithm> using namespace std; st ...
- HOJ题目分类
各种杂题,水题,模拟,包括简单数论. 1001 A+B 1002 A+B+C 1009 Fat Cat 1010 The Angle 1011 Unix ls 1012 Decoding Task 1 ...
- nordic-mesh中应用的代码实现
nordic-mesh中应用的代码实现 Nordic-Mesh遵循SIG-Mesh-Profile中的mesh定义,实现了element.model等概念. 一个应用中包含一个或多个element,e ...
- mysql: Error Codes and Messages
Appendix B. Error Codes and MessagesTable of Contents B.1. Server Error Codes and MessagesB.2. Clien ...
- MYSQL之错误代码----mysql错误代码与JAVA实现
原文地址:MYSQL之错误代码----mysql错误代码与JAVA实现作者:戒定慧 his chapter lists the errors that may appear when you call ...
- Eclipse 4.2 failed to start after TEE is installed
--------------- VM Arguments--------------- jvm_args: -Dosgi.requiredJavaVersion=1.6 -Dhelp.lucene ...
- POJ 2774 Long Long Message 后缀数组
Long Long Message Description The little cat is majoring in physics in the capital of Byterland. A ...
- poj 2774 Long Long Message 后缀数组基础题
Time Limit: 4000MS Memory Limit: 131072K Total Submissions: 24756 Accepted: 10130 Case Time Limi ...
随机推荐
- asp.net core 2.1开发环境下配置IIS
asp.net core 2.1是可以在开发环境下配置到IIS中的,这样就可以在vs中按F5直接运行了 在项目上右键点击属性,然后在Debug中配置如下参数 首先点击New按钮,输入IIS,点击确定 ...
- Auto property synthesis will not synthesize property 'delegate'; it will be implemented by its super
今天在XCode6.3上面重写TabBar的时候,自己定义tabBar的代理遇到的一个问题 在重写tabBar的代理的时候遇到了一个警告. 解决方法: 在.m文件里 警告消失
- 【java项目实战】代理模式(Proxy Pattern),静态代理 VS 动态代理
这篇博文,我们主要以类图和代码的形式来对照学习一下静态代理和动态代理.重点解析各自的优缺点. 定义 代理模式(Proxy Pattern)是对象的结构型模式,代理模式给某一个对象提供了一个代理对象,并 ...
- hdoj--2098--分拆素数和(枚举)
分拆素数和 Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Subm ...
- hdoj--1166--敌兵布阵(线段树)
敌兵布阵 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submi ...
- Python笔记(五)
# -*- coding:utf-8 -*- # 函数 # python中定义函数的规则如下:以def开头,接函数名称和(),传入的参数和变量放在圆括号中间,函数以:起始,并且缩进,return选择性 ...
- FFmpeg 移植 Android
近期项目需要解析苹果的HLS流媒体协议,而FFmpeg从0.11.1“Happiness”版本开始,才增加了对HLS协议的支持.目前网上关于FFmpeg编译移植的文章有很多,但大多都是对旧版本的说明. ...
- Python学习小计
1.初学Python最好选择2.7版本,因为大部分Python书籍的示例代码是基于这个版本的 2.Python安装可以参考百度经验完成 如果在电脑上同时安装2个版本,则CMD启动时只需要: py -2 ...
- 微软认证Hyper-V咨询工程师认证课程
课程链接:http://www.microsoftvirtualacademy.com/colleges/hyper-V-Certificate STEP 1:完成课程链接内的认证课程. STEP 2 ...
- 前端学习笔记-CSS