字符串加密

Problem : 1116

Time Limit : 1000ms

Memory Limit : 65536K

description

给你一段经过加密的字符串,我们称之为密文,现在请你编写程序输出它加密前的字符串(原文)。
已知原文中只包含26个小写字母,而密文中除了包含小写字母,还包含0~9十个数字字符,解密规则是:
1、密文中一个字母前面如果有数字x,那么原文的对应位置是在字母表中从这个字母开始向后移动x位得到的新字母。例如2a表示a向后移动2位,原文中对应就是c,再例如1z表示z向后移动1位,原文中对应就是a。
2、密文中一个字母前面如果没有数字,那么原文的对应位置就是该字母。

input

多组输入数据,每组数据只有一个加密后的字符串。长度不超过1000000,只包含数字字符和小写字母,其中连续数字的长度不超过9,最后一位一定是小写字母。

output

输出一行原字符串。

sample_input

happynewyear
25ia1op4un4a1vy3ba24t

sample_output

happynewyear
happynewyear
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string.h>
using namespace std;
char *ch="abcdefghijklmnopqrstuvwxyz";
char a[];
int main()
{
int i,k,j,shu,tmp,cou;
while(scanf("%s",a)!=-)
{
for(i=;a[i]!='\0';)
{
k=;shu=;j=;
while(a[i]>=''&&a[i]<='')
{
k++;
i++;
}//此时的i是那个字母
if(k)
{
for(cou=;cou<=k;cou++)
{
shu=shu+(((int)a[i-cou]-)*j);
j=j*;
}
tmp=(a[i]-+shu)%;
printf("%c",ch[tmp]);
}
else cout<<a[i];
i++;
}
cout<<endl;
}
return ;
}

//while。。很有趣。。。

//下面是之前超时的代码

#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string.h>
using namespace std;
char *ch="abcdefghijklmnopqrstuvwxyz";
char a[];
int main()
{
int k,shu,tmp,i;
while(scanf("%s",a)!=-)
{
for(i=;i<strlen(a);i++)
{
if(a[i]<='z'&&a[i]>='a')
{
if(a[i-]>''||a[i-]<'')
printf("%c",a[i]);
else
{
shu=(int)a[i-]-;
if(a[i-]<=''&&a[i-]>='')
shu=shu+((int)a[i-]-)*;
tmp=(a[i]-+shu)%;
printf("%c",ch[tmp]);
}
}
}
cout<<endl;
} return ;
}

nefu 1116 字符串加密的更多相关文章

  1. 利用javascript对字符串加密

    没事利用js写个对字符串加密的方法,基本原理就是先把字符串转化成对应的unicode(用到的方法是charCodeAt()),再把unicode统一减去100(这里加减随便你取多少),把得到的unic ...

  2. iOS字符串加密至MD5&及获取文件MD5

    iOS 字符串加密至MD5 #import <CommonCrypto/CommonDigest.h> + (NSString *) md5:(NSString *)str { const ...

  3. Labview实现字符串加密

    Labview实现字符串加密 对字符串进行加密,规则是每个字母后移5 位 例如A 变为F,b 变为g,x 变为c,y 变为d- 实现效果 后端实现

  4. Dotfuscator可以实现混淆代码、变量名修改、字符串加密

    C#编写的代码如果不进行一定程度的混淆和加密,那么是非常容易被反编译进行破解的,特别是对于一些商业用途的C#软件来说,因为盯着的人多,更是极易被攻破.使用VS自带的Dotfuscator可以实现混淆代 ...

  5. C# 字符串加密解密方法

    这个是加密的算法的命名空间,使用加密算法前要引用该程序集  System.Security.Cryptography using System;using System.Data;using Syst ...

  6. 敏感字符串加密处理(PHP实现)

    /** * 敏感字符串加密处理 * @param $raw_str 原始字符串 * @param $before 前面保留的显示位数 * @param $after 后面保留的显示位数 * @para ...

  7. C# 字符串加密解密函数

    原文:C# 字符串加密解密函数 using System; using System.Text;using System.Security.Cryptography; using System.IO; ...

  8. Java对字符串加密并返回星号※

     If you don't look back, you'll never know I waiting for you behind you. Java对字符串加密并返回星号※ PasswordUt ...

  9. 从网上整理的一些delphi字符串加密解密方法

    function Encode(Str: string): string; var //加密 TmpChr: AnsiChar; i, Len: integer; begin Result := St ...

随机推荐

  1. JAVA中String(字符串)课堂总结

    一:Java编译器中关于字符串自动优化 例子一: 源代码: public class StringPool { public static void main(String args[]) { Str ...

  2. angularjs中sortable的使用

    将每个li并列排序,同时可以实现拖拉排序功能 html: js:使用的插件:html.sortable.angularjs,html.sortable.js 实现的效果: 通过js中sortableO ...

  3. Char device registration

    The kernel uses structures of type struct cdev to represent char devices internally. Include <lin ...

  4. openstack私有云布署实践【0 前言】

    管理控制层面示图: 其实在修改这个布署文档是,我发现当时生产中的布署已经严重偏离了openstack高可用的指导思想.我们自己实践的高可用其实是适应自己的架构而做的调整,因为我们现实手头上中没有比较符 ...

  5. hdu1012

    #include<iostream>#include<stdio.h> using namespace std; int jiechen(int n){    int i;   ...

  6. iOS开发讯飞语音的集成

    1.进入官网注册账号,登陆,注册,应用. 2,下载sdk  导入系统库. 3,关闭bitcode 4,初始化讯飞语音. NSString * initString = [[NSString alloc ...

  7. SPFA算法与dijkstra算法求单源最短路径的比较

    SPFA是运用队列,把所有的点遍历到没有能更新的,点可以重复入队 如题http://www.cnblogs.com/Annetree/p/5682306.html dijkstra是每次找出离源点最近 ...

  8. A - LCM Challenge

    A - LCM Challenge Time Limit: 2000/1000MS (Java/Others)    Memory Limit: 128000/64000KB (Java/Others ...

  9. ural 1091. Tmutarakan Exams(容斥原理)

    1091. Tmutarakan Exams Time limit: 1.0 secondMemory limit: 64 MB University of New Tmutarakan trains ...

  10. js预编译

    先来做三个测试 eg1: var a; a = 1; function a() {}; console.log(a); eg2: var a; function a() {}; console.log ...