B - Encoded Love-letter 字符串的处理
Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u
Description
Each charactor are changed to a corresponding charactor. If the keyword is "Angel", the rule will be:
ABCDEFGHIJKLMNOPQRSTUVWXYZ
ANGELZYXWVUTSRQPOMKJIHFDCB
You may find that in the bottom line, charactors of the keyword come first. All other charactors will come in a reversed order.
Now given another keyword, work the letter out!
Can you write a program to translate the letter?
Input
Output
the letter and print it out. Please note that a upper-case charactor
will be decoded to a upper-case charactor, while a lower-case charactor
will be decoded to a lower-case charactor.
Sample Input
Fxlr jxaj eac W xlam cqim hqwgl
W xahl kqsl kplgwat zlltwry
Tlj sl atfack jxwru W eqr'j farra zqmylj cqi
W mlslsnlm aj jxl eac
Cqi aml atfack qr sc swre
Lhlrjxqiyx W vikj gar jxwru anqij cqi
Wz jxl eac wr jxl zijiml
Jxwk tqhl fwtt nlgqswry jmil
W'hl rlhlm gxaryl sc swre jxaj W fwtt tqhl cqi zqmlhlm
W eqr'j gaml xqf zqqt wj wk
W fwtt tlj sc emlas gqsl jmil
W fwtt jltt cqi kqsljxwry W farra tlj cqi urqf, W tlj cqi urqf
W tqhl cqi, tqhwry cqi, ak jxl sqikl tqhlk jxl mwgl
Lhlr lhlmc eac xak kjqms, W fwtt atfack nc cqim kwel
W swkk cqi, swkkwry cqi
W eqr'j gaml xqf xame wj wk
W vikj farj cqi jq nl xappc
Lhlmcjxwry, W eq wj zqm cqi
Sample Output
I have some special feeling
Let me always think I don't wanna forget you
I remember at the day
You are always on my mind
Eventhough I just can think about you
If the day in the future
This love will becoming true
I've never change my mind that I will love you forever
I don't care how fool it is
I will let my dream come true
I will tell you something I wanna let you know, I let you know
I love you, loving you, as the mouse loves the rice
Even every day has storm, I will always by your side
I miss you, missing you
I don't care how hard it is
I just want you to be happy
Everything, I do it for you
#include<cstdio>
#include<string.h>
using namespace std;
char f[]="1ABCDEFGHIJKLMNOPQRSTUVWXYZ";
char f1[];
int ff[];
char str[];
char s[];
int main()
{
int i,j;
int len;
scanf("%s",str);
//puts(str);
getchar();
len=strlen(str);
memset(ff,,sizeof(ff));
memset(f1,,sizeof(f1));
for(i=; i<=len; i++)
{
f1[i]=str[i-];
ff[str[i-]-'A'+]=;
//printf("%d ",ff[str[i-1]-'A'+1]);
}
j=i;
for(i=; i>=; i--)
if(ff[i]==)
{
f1[j++]='A'-+i;
//printf("%c ",f1[j-1]);
}
//printf("%s",f1);
while(gets(s))
{
len=strlen(s);
for(i=;i<len;i++)
{
if(s[i]>='A'&&s[i]<='Z')
{
for(j=;j<=;j++)
if(s[i]==f1[j]) printf("%c",f[j]);
} else if(s[i]>='a'&&s[i]<='z')
{
for(j=;j<=;j++)
if(s[i]-'a'+'A'==f1[j]) printf("%c",f[j]-'A'+'a');
} //else if(s[i]==0) printf("\n");
else printf("%c",s[i]);
}
printf("\n");
} return ;
}
B - Encoded Love-letter 字符串的处理的更多相关文章
- Python基础->for循环、字符串以及元组
python流程控制>for循环.字符串以及元组 学习有关序列的思想.序列:一组有顺序的东西.所有的序列都是由元素组成的,序列中的元素位置是从0开始编号的,最后一个元素的位置是它长度减一. fo ...
- 《think in python》学习-8
字符串 字符串是一个序列,可以用方括号操作符来访问字符串中的单独字符 fruit = 'banana' letter = fruit[1] 方括号中的表达式称为下标 下标从0 开始 任何表达式,包括变 ...
- [Swift]LeetCode917. 仅仅反转字母 | Reverse Only Letters
Given a string S, return the "reversed" string where all characters that are not a letter ...
- php json_encode 返回false
今天用ajax请求不到数据,发现问题出现在最后一句 echo json_encode($data); var_dump(json_encode($data));输出false 使用json_last_ ...
- 12-4 NSString
原文:http://rypress.com/tutorials/objective-c/data-types/nsstring NSString 在本教程的内容可能我们已经看到过很多次了,NSStri ...
- Html5——File、FileReader、Blob、Fromdata对象
File File 接口提供有关文件的信息,并允许网页中的JavaScript访问其内容. File对象可以用来获取某个文件的信息,还可以用来读取这个文件的内容.通常情况下,File对象是来自用户在一 ...
- Spring Boot项目中使用 TrueLicense 生成和验证License(服务器许可)
一 简介 License,即版权许可证,一般用于收费软件给付费用户提供的访问许可证明.根据应用部署位置的不同,一般可以分为以下两种情况讨论: 应用部署在开发者自己的云服务器上.这种情况下用户通过账号登 ...
- 劳动节快乐!手写个核心价值观编码工具 - Python实现
前言 今天是五一劳动节,祝各位无产阶级劳动者节日快乐! 然后来整活分享一些有趣的东西~ 这个小工具是我大学时做着玩的,对于各位接班人来说,12个词的核心价值观这东西,大家都非常熟悉了,这工具可以实现将 ...
- HDU 1591 Encoded Love-letter(简单字符串)
Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission( ...
随机推荐
- PHP 可变长度参数列表
In PHP 5.6 and later, argument lists may include the ... token to denote that the function accepts a ...
- 20.fastDFS集群java代码测试
1.工程结构 2.代码内容 FastdfsClientTest.java代码 package cn.itcast.fastdfs.cliennt; import java.io.File; i ...
- PHP-----二维数组和二分查找
二维数组由行和列组成.由arr[$i][$j]表示,先后表示行和列,类似于坐标点. 打印二维数组-----通过两次遍历,第一次遍历每一行,第二次遍历每一行的具体元素,并且通过使用count($arr[ ...
- grunt压缩合并代码
module.exports = function(grunt) { // 配置 grunt.initConfig({ pkg : grunt.file.readJSON('package.json' ...
- 根据多年经验整理的《互联网MySQL开发规范》
一.基础规范 使用 INNODB 存储引擎 表字符集使用 UTF8 所有表都需要添加注释 单表数据量建议控制在 5000W 以内 不在数据库中存储图⽚.文件等大数据 禁止在线上做数据库压力测试 禁⽌ ...
- IDEA maven项目 包不能导入问题 全是红线
情况如图所示,红线的话里肯定是没有maven包的 1.检查pom.xml是否报错 报错 右键添加一下 2.点击 3.出现错误提示 4.百度解决
- thinkphp分页搜索条件带中文参数
/** * 中文处理 * @param type $str * @return str * $author lxh */ function url2word($str){ $sub=strpos($s ...
- [kylin] 部署kylin服务
一.工具准备 zookeeper3.4.6 (hadoop.hbase 管理工具) Hadoop. Hbase1.1.4 Kylin1.5.0-HBase1.1.3 Jdk1.7.80 Hive 二. ...
- 解决在国内更新android sdk时连不到服务器的问题
修改hosts文件 Windows下:打开C:\Windows\System32\drivers\etc\hosts Linux下:vi /etc/hosts 在文件尾加入如下两行: 74.125.2 ...
- Android开发--EditText的应用
1.简介 EditText主要用于数据的输入,验证等问题.例如,账号的注册,验证等等. 2.构建 如下图所示,在Text Fields有多种类型的数据输入框,我们创建图2所示的文本框,当点击按钮时,文 ...