SDUT 3189 Reverse Rot(水题)
来源:互联网 发布:golang select 编辑:程序博客网 时间:2024/06/05 06:22
Reverse Rot
Time Limit: 1000MS Memory limit: 65536K
题目描述
A very simplistic scheme, which was used at one time to encode information, is to rotate the characters within an alphabet and rewrite them. ROT13 is the variant in which the characters A-Z are rotated 13 places, and it was a commonly used insecure scheme that attempted to "hide" data in many applications from the late 1990\'s and into the early 2000\'s.
It has been decided by Insecure Inc. to develop a product that "improves" upon this scheme by first reversing the entire string and then rotating it. As an example, if we apply this scheme to string ABCD with a reversal and rotation of 1, after the reversal we would have DCBA and then after rotating that by 1 position we have the result EDCB.
Your task is to implement this encoding scheme for strings that contain only capital letters, underscores, and periods. Rotations are to be performed using the alphabet order:
ABCDEFGHIJKLMNOPQRSTUVWXYZ_.Note that underscore follows Z, and the period follows the underscore. Thus a forward rotation of 1 means \'A\' is shifted to \'B\', that is,
输入
输出
示例输入
1 ABCD3 YO_THERE.1 .DOT14 ROAD9 SHIFTING_AND_ROTATING_IS_NOT_ENCRYPTING2 STRING_TO_BE_CONVERTED1 SNQZDRQDUDQ0
示例输出
EDCBCHUHKWBR.UPEAROADPWRAYF_LWNHAXWH.RHPWRAJAX_HMWJHPWRAORQ.FGVTGXPQEAGDAQVAIPKTVUREVERSE_ROT
提示
来源
示例程序
#include<iostream>#include<algorithm>#include<stdio.h>#include<string.h>#include<stdlib.h>#include<queue>#include<stack>#include<vector>#include<math.h>#include<map>#define inf 0x3f3f3f3fusing namespace std;char a[101];int n;int main(){ while(scanf("%d",&n)!=EOF) { if(n == 0) { break; } scanf("%s",a); int len = strlen(a); n = n%28; for(int i=len-1;i>=0;i--) { if(a[i] == '.') { if(n == 27) { printf("_"); } else { printf("%c",'A'+n-1); } continue; } if(a[i] == '_') { if(n == 1) { printf("."); } else { printf("%c",'A'+n-2); } continue; } if(a[i]+n>'Z') { if(a[i]+n-'Z' == 1) { printf("_"); } else if(a[i]+n-'Z' == 2) { printf("."); } else { printf("%c",'A'+a[i]+n-'Z'-3); } } else { printf("%c",a[i]+n); } } printf("\n"); } return 0;}
- SDUT 3189 Reverse Rot(水题)
- CSU1567: Reverse Rot(水题)
- csu 1567: Reverse Rot
- CSU1567:Reverse Rot(DFS)
- CSU-1567-Reverse Rot
- CSU 1567Reverse Rot
- csu 1567 Reverse Rot
- CSU1567 Reverse Rot
- CSU1567-Reverse Rot
- CSU 1567 Reverse Rot
- Reverse Rot Contest2073 - 湖南多校对抗赛(2015.04.06)G
- ROT-13
- ROT-13
- SDUT 8600手机(水题)
- SDUT Problem_5 二哥的狗(水题)
- SDUT 小金防呀防不住_AK (水题)
- Link Rot检测
- 学习BLAS库 -- ROT
- C语言中不安全的函数以及解决方案
- Java学习5--File类
- PostgreSQL 客户端下查看表,视图,function,切换数据库等
- MySQL索引背后的数据结构及算法原理
- cfx3.0.4必备jar包
- SDUT 3189 Reverse Rot(水题)
- PopupWindow基础设置
- C#对象序列化与反序列化
- 用Java编写自己的机器人 Robot类的应用
- 不会是应该的么
- POJ 1573 & POJ 2632(两道有趣的Robot)实例
- StoryBoard+AutoLayout实战开发小技巧
- pg_restore数据库恢复指令
- 任正非接班人李一男离开华为时给属下的忠告