当前位置:网站首页>One question per day,
One question per day,
2022-06-25 14:50:00 【䨁 逦】
Title Description
The keyboard of a mobile phone is like this :
You have to press the number key many times to press the English letters . For example, to press x
Just press 9 both parties , The first one will come out w
, And the second one will w
become x
.0 Press the key once and a space will appear .
Your task is to read several sentences that contain only lowercase letters and spaces , Find out at least how many keystrokes you need to press to type this sentence on your mobile phone .
Input format
A line of sentences , Contains only lowercase letters and spaces , And no more than 200 Characters .
Output format
One line, one integer , Indicates the total number of keystrokes .
I/o sample
Input #1 Copy
i have a dream
Output #1 Copy
23
code
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
char c[205];
int main(){
int all=0,n=0;
while((c[n]=getchar())!=EOF)
{
n++;
}
for(int i=0;i<n;i++)
{
if(c[i]==' ') all++;
else
if('a'<=c[i]&&c[i]<='r')
{
int a=0;
a= c[i]-'a'+1;
if(a%3==0)
all+=3;
else
all=a%3+all;
printf("%d\n",all);
}
else
if(c[i]=='p'||c[i]=='t'||c[i]=='w')
all++;
else
if(c[i]=='q'||c[i]=='u'||c[i]=='x')
all+=2;
else
if(c[i]=='r'||c[i]=='v'||c[i]=='y')
all+=3;
else
if(c[i]=='s'||c[i]=='z')
all+=4;
}
printf("%d",all);
return 0;
}
边栏推荐
- 弹性布局(display:flex;)属性详解
- Extend JS copy content to clipboard
- Page 112 machine learning - review of fundamentals of mathematics pptx
- For the first time in China, Chinatelecom 5g underground personnel positioning project is officially commercial: it can track the position in real time to ensure operation safety
- Add the resources directory under test in idea
- [Ocean University of China] information sharing for the first and second examinations of postgraduate entrance examination
- How to make GIF animation online? Try this GIF online production tool
- Renix perf: detailed explanation of IP network performance test tools and test case parameters
- QQ情话糖果情话内容获取并保存
- How to view the Chrome browser plug-in location
猜你喜欢
Reading the "clean" series for the first time, I didn't think it was a good book
Build a minimalist gb28181 gatekeeper and gateway server, establish AI reasoning and 3D service scenarios, and then open source code (I)
合宙Air32F103CBT6开发板上手报告
Renix perf: detailed explanation of IP network performance test tools and test case parameters
关于win10 版本kicad 卡死的问题, 版本6.x
从408改考自主命题,211贵州大学考研改考
About the problem of kicad stuck in win10 version, version 6 x
Uniapp icon configuration
SPARQL learning notes of query, an rrdf query language
Uniapp cloud packaging app
随机推荐
90 后眼中的理想 L9:最简单的产品哲学,造最猛的爆款 | 指南斟
关于win10 版本kicad 卡死的问题, 版本6.x
多张动图怎样合成一张gif?仅需三步快速生成gif动画图片
Add the resources directory under test in idea
HMS Core机器学习服务实现同声传译,支持中英文互译和多种音色语音播报
Clinical chemistry | zhangjianzhong / Xu Jian develop single cell precision diagnosis and treatment technology for Helicobacter pylori
Dmsetup command
How to combine multiple motion graphs into a GIF? Generate GIF animation pictures in three steps
Using Sphinx to automatically generate API documents from py source files
Is it safe to open an online stock account? Who knows
Sequential programming 1
Renix perf: detailed explanation of IP network performance test tools and test case parameters
QT file reading -qfile
有哪个瞬间让你觉得这个世界出bug了?
【Try to Hack】vulnhub DC1
还没弄明白微服务数据架构事务管理+ACID+一致性+CAP+BASE理论吗,看完彻底解决疑惑
Summary of common functions in Oracle Database
What is the safest app for stock account opening? Tell me what you know
HMS core machine learning service realizes simultaneous interpretation, supports Chinese-English translation and multiple voice broadcast
About the problem of kicad stuck in win10 version, version 6 x