POJ1107 W's Cipher 简单模拟
来源:互联网 发布:二次元背景拍照软件 编辑:程序博客网 时间:2024/04/30 12:55
POJ1107 W’s Cipher
Description
先是将字母和下划线分为三类a~i,j~r,s~z和‘_’; 然后,独立地交换每组的字母,例如:对于 “_icuo_bfnwhoq_kxert”,第一组符号有{i,c,b,f,h,e},位置分别为{2,3,7,8,11,17},假设k1=2;那么第一组符号顺序变为{h,e,i,c,b,f},不过在原字符串中占有的位置还是{2,3,7,8,11,17},然后第二组······第三组······
Sample Input
2 3 1
_icuo_bfnwhoq_kxert
1 1 1
bcalmkyzx
3 7 4
wcb_mxfep_dorul_eov_qtkrhe_ozany_dgtoh_u_eji
2 4 3
cjvdksaltbmu
0 0 0
Sample Output
the_quick_brown_fox
abcklmxyz
the_quick_brown_fox_jumped_over_the_lazy_dog
ajsbktcludmv
题解:
整理ing
AC_Code(cpp):
#include<iostream>using namespace std;struct mychar{ char character; int position;};void Decrypted(char encrypted[], int k1, int k2, int k3){ char decrypted[100]=""; mychar char1[100]; mychar char2[100]; mychar char3[100]; int count1 = 0; int count2 = 0; int count3 = 0; int len = strlen(encrypted); for (int i = 0; i < len; i++) { if (encrypted[i] >= 's' || encrypted[i] == '_') { char3[count3].character = encrypted[i]; char3[count3].position = i; count3++; } else if (encrypted[i] >= 'j') { char2[count2].character = encrypted[i]; char2[count2].position = i; count2++; } else { char1[count1].character = encrypted[i]; char1[count1].position = i; count1++; } } for (int i = 0; i < count3; i++) { decrypted[char3[(i + k3) % count3].position] = char3[i].character; } for (int i = 0; i < count2; i++) { decrypted[char2[(i + k2) % count2].position] = char2[i].character; } for (int i = 0; i < count1; i++) { decrypted[char1[(i + k1) % count1].position] = char1[i].character; } cout << decrypted << endl;}int main(){ int k1, k2, k3; char encrypted[100]=""; while (cin >> k1 >> k2 >> k3 && (k1 + k2 + k3)) { cin >> encrypted; Decrypted(encrypted, k1, k2, k3); } return 0;}
0 0
- POJ1107 W's Cipher 简单模拟
- POJ1107 W's Cipher
- POJ1107 W's Cipher 【水题】
- poj1107 W's Cipher(字符串)
- POJ 1107 W's Cipher(模拟)
- 1042 W's Cipher
- ZOJ1042-W`s Cipher
- ZJU1042-W‘s Cipher
- POJ 1107 W's Cipher (模拟解密)
- POJ 1107 : W\'s Cipher - 密码,字符串模拟
- 文章标题poj 1107:W's Cipher (模拟)
- poj 1107 --W's Cipher
- poj 1107W's Cipher
- zoj 1042 W's Cipher
- zoj 1042 W's Cipher
- POJ 1107 W's Cipher
- ZOJ 1042 W's cipher
- POJ 1107 W's Cipher
- django常用函数
- FastDFS的配置、部署与API使用解读(4)FastDFS配置详解之Client配置
- js实现懒加载
- Nodejs异步流程控制Async
- Markdown简明教程
- POJ1107 W's Cipher 简单模拟
- 优化MyBatis配置文件中的配置
- php,c# hamsha1
- iOS AFN2.0请求封装使用
- Dubbo与Zookeeper、SpringMVC整合和使用(负载均衡、容错)
- 设计模式C++实现--策略模式
- linux下diff多个目录的脚本
- Method Swizzling
- 深入浅出REST