当前位置:网站首页>测试第一题
测试第一题
2022-07-30 05:46:00 【缘聚654】
题目描述
一般的手机的键盘是这样的:

要按出英文字母就必须要按数字键多下。例如要按出 x 就得按 9 两下,第一下会出 w,而第二下会把 w 变成 x。0 键按一下会出一个空格。
你的任务是读取若干句只包含英文小写字母和空格的句子,求出要在手机上打出这个句子至少需要按多少下键盘。
输入格式
一行句子,只包含英文小写字母和空格,且不超过 200 个字符。
输出格式
一行一个整数,表示按键盘的总次数。
输入输出样例
输入 #1复制
i have a dream
输出 #1复制
23
#include<stdio.h>
int main()
{
int x,y,z,n,s,t;
char ch;
x=0;y=0;z=0;n=0;s=0;
do
{
scanf("%c",&ch);
if(ch=='a'||ch=='d'||ch=='g'||ch=='j'||ch=='m'||ch=='p'||ch=='t'||ch=='w')
x=x+1;
else if(ch=='b'||ch=='e'||ch=='h'||ch=='k'||ch=='n'||ch=='q'||ch=='u'||ch=='x')
y=y+2;
else if(ch=='c'||ch=='f'||ch=='i'||ch=='l'||ch=='o'||ch=='r'||ch=='v'||ch=='y')
z=z+3;
else if(ch=='s'||ch=='z')
n=n+4;
else if(ch==' ')
s=s+1;
}while(ch!='\n');
t=x+y+z+n+s;
printf("%d",t);
}
i have a dream
23
-------------------边栏推荐
猜你喜欢

【速成MSP430f149】电赛期间学习MSP430f149笔记
Three working modes of CPU: real mode, protected mode, long mode

【已解决:el-input标签无法输入或不显示文字】

i++与 ++i 的区别

TCP建立连接的过程

Duplicate keys detected:‘/da…‘
![[Jiangsu University Self-Chemistry Association stm32F103c8t6] Notes [Entry 32 MCU and GPIO initialization parameter configuration]](/img/96/a98e8b813a2fd9d0a44d3121aaee6a.png)
[Jiangsu University Self-Chemistry Association stm32F103c8t6] Notes [Entry 32 MCU and GPIO initialization parameter configuration]
![Massive remote sensing data processing and application of GEE cloud computing technology [basic, advanced]](/img/38/239933ac987da762135db2d13902d0.png)
Massive remote sensing data processing and application of GEE cloud computing technology [basic, advanced]
![[Quick MSP430f149] Notes on learning MSP430f149 during the game](/img/06/741c609b24be007718091b8348666c.png)
[Quick MSP430f149] Notes on learning MSP430f149 during the game

Explore the efficiency of make_shared
随机推荐
Kunlun State Screen Production (serialization 4) --- Basics (graphical setting and display, button lights)
OpenLayers (ol包),Vite显示地图(附源码)
Insertion Sort in Classic Sort
Machine Learning, Deep Learning Based on MATLAB 2021b
clinit方法
【江科大自化协stm32F103c8t6】笔记之【入门32单片机及利用TIM输出比较配置PWM】
led闪烁
ES6 syntax notes (ES6~ES11)
二进制到汇编:进制,原码反码补码,位运算,通用寄存器,内存一套打通
关于报错vscode
The IEEE under the specified journal search related papers
信号链模拟芯片是什么?
VSCode hides the left activity bar
js 替换字符串中所有 “ 引号 —— 数据处理
数码管动态显示及模块化编程
TCP建立连接的过程
[Punctuality Atom] Learning and use of IIC (unfinished...)
使用Dva项目作Antd的Demo
VsCode连接远程服务器并修改文件代码
你不知道的JS语法篇笔记