题解 | #手机键盘#

手机键盘

http://www.nowcoder.com/practice/20082c12f1ec43b29cd27c805cd476cd

include<stdio.h>

include<string.h>

int KeyTable[26]={1,2,3,1,2,3,1,2,3,1,2,3,1,2,3,1,2,3,4,1,2,3,1,2,3,4};
int main()
{
char str[200];
while(scanf("%s",str)!=EOF)
{
int time=0;
int len=strlen(str);
for(int i=0;i<len;i++)
{
time+=KeyTable[str[i]-'a'];
if(i!=0&&str[i]-str[i-1]==KeyTable[str[i]-'a']-KeyTable[str[i-1]-'a'])
{
time+=2;
}
}
printf("%d",time);
}
}

全部评论

相关推荐

萧索X:写篮球联赛干嘛,陪老板打篮球吗。还有实习经历要写自己所在岗位具体完成什么工作,自己的任务具体完成了什么需求,给公司带来了哪些量化增长
点赞 评论 收藏
分享
评论
5
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务