首页 > ACM题库 > 九度OJ > 九度-1538-GrassLand密码[解题代码]
2013
12-13

九度-1538-GrassLand密码[解题代码]

题目描述:

由于害怕别人偷玩他的新手机,GrassLand总是为其手机加上锁屏密码。但是毫无规律的密码又不方便自己记忆,于是他有了这么一个主意:
首先GrassLand会有一个仅包含小写字母的明文密码,如horse。
然后,他按照九宫格键盘上字母的标注(下图),将字母转化为相应的数字按键。如h出现在按键4上,那么其对应的数字为4。

按照这个规则,GrassLand的明文密码被加密为46773。
现在他需要你为他编写一个程序来完成这个加密过程,生成密码。

输入:

输入包含多组测试数据,每组测试数据一行,包含一个仅包含小写字母的字符串,其长度小于10000。

输出:

对于每组测试用例,输出为一个仅包含数字的字符串,代表加密后的密码。

样例输入:
horse
strawberry
样例输出:
46773
7872923779

cpp 代码如下:
#include <stdio.h>
int map[] = {2,2,2,3,3,3,4,4,4,5,5,5,6,6,6,7,7,7,7,8,8,8,9,9,9,9},i;
char str[10000];
int main() {
	while(gets(str)){
		for(i=0; str[i]; i++) str[i]=map[str[i]-97]+'0';
		puts(str);
	}
	return 0;
}
/**************************************************************
	Problem: 1538
	User: coder
	Language: C
	Result: Accepted
	Time:40 ms
	Memory:924 kb
****************************************************************/


  1. 这道题目的核心一句话是:取还是不取。
    如果当前取,则index+1作为参数。如果当前不取,则任用index作为参数。

  2. Hello Web Admin, I noticed that your On-Page SEO is is missing a few factors, for one you do not use all three H tags in your post, also I notice that you are not using bold or italics properly in your SEO optimization. On-Page SEO means more now than ever since the new Google update: Panda. No longer are backlinks and simply pinging or sending out a RSS feed the key to getting Google PageRank or Alexa Rankings, You now NEED On-Page SEO. So what is good On-Page SEO?First your keyword must appear in the title.Then it must appear in the URL.You have to optimize your keyword and make sure that it has a nice keyword density of 3-5% in your article with relevant LSI (Latent Semantic Indexing). Then you should spread all H1,H2,H3 tags in your article.Your Keyword should appear in your first paragraph and in the last sentence of the page. You should have relevant usage of Bold and italics of your keyword.There should be one internal link to a page on your blog and you should have one image with an alt tag that has your keyword….wait there's even more Now what if i told you there was a simple WordPress plugin that does all the On-Page SEO, and automatically for you? That's right AUTOMATICALLY, just watch this 4minute video for more information at.