poj 1107W's Cipher
来源:互联网 发布:传奇db数据库参数 编辑:程序博客网 时间:2024/05/17 02:35
题意:
给定字符串可分为三个部分:Encrypting a message requires three integer keys, k1, k2, and k3. The letters [a-i] form one group, [j-r] a second group, and everything else ([s-z] and underscore) the third group.k1代表first group 右移的步数(仅在这一部分中),k2, k3同理。
思路:很简单,对每一部分进行移位。可另设数组存储每一部分,对原串进行更改。
代码:
#include <iostream>#include <cstdio>#include <cstring>using namespace std;#define FOR(i, n) for(i = 0; i < (n); ++i)#define FORE(i, a, b) for(i = (a); i <= (b); ++i)struct node{ char c; int id;};int main(){ int k1, k2, k3, i, len; char s[100]; node g1[100],g2[100],g3[100]; while(scanf("%d %d %d", &k1, &k2, &k3)!=EOF && (k1+k2+k3)!=0){ memset(s, 0, sizeof(s)); scanf("%s", s); len = strlen(s); int c1 = 0, c2 = 0, c3 = 0; FOR(i, len){ if(s[i] >= 'a' && s[i] <= 'i'){ g1[c1].id = i; g1[c1++].c = s[i]; } else if(s[i] >= 'j' && s[i] <= 'r'){ g2[c2].id = i; g2[c2++].c = s[i]; } else{ g3[c3].id = i; g3[c3++].c = s[i]; } } FOR(i, c1) s[g1[(i+k1)%c1].id] = g1[i].c; FOR(i, c2) s[g2[(i+k2)%c2].id] = g2[i].c; FOR(i, c3) s[g3[(i+k3)%c3].id] = g3[i].c; printf("%s\n",s); } return 0;}
- poj 1107 --W's Cipher
- poj 1107W's Cipher
- POJ 1107 W's Cipher
- POJ 1107 W's Cipher
- POJ - 1107 W's Cipher
- POJ 1107 W's Cipher 解密
- POJ 1107 W's Cipher(模拟)
- poj 1107 (jobdu 1485) W's Cipher AC代码
- POJ 1107 W's Cipher (模拟解密)
- POJ 1107 : W\'s Cipher - 密码,字符串模拟
- Poj.1107 W's Cipher【水题】 2015/04/22
- 文章标题poj 1107:W's Cipher (模拟)
- POJ 1107 W's Cipher 已被翻译
- 1042 W's Cipher
- POJ1107 W's Cipher
- ZOJ1042-W`s Cipher
- ZJU1042-W‘s Cipher
- zoj 1042 W's Cipher
- 地址栏图标不对的解决办法
- 多维数据库的数据存储
- 使我困扰的几个C++程序
- J2ME 走向成熟(long long ago)
- SICP Exercise 4.3
- poj 1107W's Cipher
- 关闭Apache的目录浏览功能
- IMX51, SD驱动
- PHP5 VC9、VC6、Thread Safe、Non Thread Safe各个版本区别
- USB HID设备报告描述符详解
- 解决Windows Installer 无法打开此修补程序包的问题
- 四、运算符(例2)
- C语言基础笔记...(待续...)
- java开发大全。。第二十一章News报错,