博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
1569. Encrypted SMS
阅读量:5861 次
发布时间:2019-06-19

本文共 1327 字,大约阅读时间需要 4 分钟。

挺水的,简单按照题意模拟就行

-------------------------------------------------

 1 #include <iostream>

 2 #include <string.h>
 3 using namespace std;
 4 int w2[3]={
0,1,2};
 5 int w3[3]={
3,4,5};
 6 int w4[3]={
6,7,8};
 7 int w5[3]={
9,10,11};
 8 int w6[3]={
12,13,14};
 9 int w7[4]={
15,16,17,18};
10 int w8[3]={
19,20,21};
11 int w9[4]={
22,23,24,25};
12 int wc[26]={
3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,4,4,4,4,3,3,3,4,4,4,4};
13 int wp[26]={
0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,3,0,1,2,0,1,2,3};
14 char w[100];
15 int main()
16 {
17         cin>>w;
18         while(strcmp(w,"#")!=0)
19         {
20                 int len=strlen(w);
21                 for(int i=0;i<len;i++)
22                 {
23                         int* tem;
24                         int c;
25                         if(w[i]>='A'&&w[i]<='Z')
26                                 c=w[i]-'A';
27                         if(w[i]>='a'&&w[i]<='z')
28                                 c=w[i]-'a';
29                 //    cout<<w[i]<<c<<endl;
30                         int n=wc[c];
31                 //    cout<<n<<endl;
32                         int p=wp[c];
33                 //    cout<<p<<endl;
34                         if(c<=2)
35                                 tem=w2;
36                         else if(c<=5)
37                                 tem=w3;
38                         else if(c<=8)
39                                 tem=w4;
40                         else if(c<=11)
41                                 tem=w5;
42                         else if(c<=14)
43                                 tem=w6;
44                         else if(c<=18)
45                                 tem=w7;
46                         else if(c<=21)
47                                 tem=w8;
48                         else if(c<=25)
49                                 tem=w9; 
50                         for(int j=0;j<=i;j++)
51                         {
52                                 p--;
53                                 if(p<0)
54                                         p=n-1;
55                         }
56                         char ans;
57                         if(w[i]>='A'&&w[i]<='Z')
58                                 ans=tem[p]+'A';
59                         if(w[i]>='a'&&w[i]<='z')
60                                 ans=tem[p]+'a';
61                         cout<<ans;
62                 }
63                 cout<<endl;
64                 cin>>w;
65         }
66 }

转载于:https://www.cnblogs.com/congzc/archive/2011/05/08/2329974.html

你可能感兴趣的文章
spring cloud(八):Turbine的应用
查看>>
35 个快速学习编程的好去处
查看>>
远程查看windows2003服务器日志文件
查看>>
Weblogic 10.3.6 for linux 集群安装
查看>>
js 中map集合
查看>>
局域网WEB方式实现TTS实时语音合成
查看>>
逻辑卷的创建
查看>>
awk使用案例一例
查看>>
【Windows Server 2019】域控管理員組別登陸計算機無效?
查看>>
svn clean up 异常的解决办法
查看>>
IE设为主页、收藏本页、联系我们
查看>>
JavaScript之事件绑定
查看>>
tushare做量化投资分析
查看>>
监控软件cacti之安装
查看>>
【Java数据结构】3.2链式栈
查看>>
[Kafka]消息中间件—简谈Kafka中的NIO网络通信模型
查看>>
google play Service导入
查看>>
HTML5 doctype
查看>>
django RESTful研究一第一个测试例子
查看>>
使用Composer安装Yii2
查看>>