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 ...
随机推荐
- 用友ERP T6技术解析(六) 库龄分析
2.4 库存管理 2.4.1 库龄分析 介绍:库存账龄是在某时间节点,某种或某类存货的库存时间的加权平均值,跟库存周转率关系明显,库存周转率越高,库存账龄越低,可是二者又不是反比关系.不能简单把库 ...
- nyoj 119 士兵杀敌(三) 【线段树】【单点更新】
题意:. .. 策略如题. 思路:我们先如果仅仅求某一区间的最大值.我们仅仅须要利用线段树的模板.仅仅须要初始化和询问的时候小小的改动一下.改成祖先结点储存的不再是子节点的和而是两个子节点之间的最大值 ...
- AlertDialog自己定义View的使用方法+怎样改变弹出框的大小
android系统定义了弹出框,支持我们自己定义布局: public AlertDialog getEditCustomDialog() { LayoutInflater inflater = get ...
- Codeforces Round #316 (Div. 2)E. Pig and Palindromes DP
E. Pig and Palindromes Peppa the Pig was walking and walked into the forest. What a strange coinci ...
- MyEclipse2015安装SVN插件
一.下载SVN插件subclipse 下载地址:http://subclipse.tigris.org/servlets/ProjectDocumentList?folderID=2240 在打开的网 ...
- 0x17 二叉堆
优先队列太好用了手写啥呀 poj1456 经过贪心专题的洗礼以后这题根本就不叫题啊...按时间大到小排每次取最大就好 #include<cstdio> #include<iostre ...
- 【NOI 2002】 银河英雄传说
[题目链接] https://www.luogu.org/problemnew/show/P1196 [算法] 并查集 [代码] #include<bits/stdc++.h> using ...
- js 智能识别收获地址
项目地址https://github.com/wzc570738205/smart_parse 支持以下数据格式 马云,1351111111,北京市朝阳区姚家园3楼 马云1351111111北京市朝阳 ...
- sql server 启用数据库的 Service Broker
使用SqlDependency时要开启Service Broker ,那么SqlDependency是什么 https://www.cnblogs.com/zhaoyihao/p/5663258.ht ...
- (转载)Android快速开发偷懒必备,一句话搞定所有ViewGroup的Adapter . 支持自定义ViewGroup
[置顶] [Android]快速开发偷懒必备,一句话搞定所有ViewGroup的Adapter . 支持自定义ViewGroup 标签: androidAdapter快速开发0耦合 2016-12-1 ...