当前位置:网站首页>测试第一题
测试第一题
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
-------------------边栏推荐
- ------实现二叉搜索树BST
- js 替换字符串中所有 “ 引号 —— 数据处理
- Diwen serial screen production (serialization 1) ===== preparation work
- The IEEE under the specified journal search related papers
- Delete all files containing a keyword in the current path
- c语言编程练习
- NS3报错 fatal error: ns3/opengym-module.h: No such file or directory
- 编程测试6.21
- 三种内核结构---宏内核、微内核、混合内核
- 《C陷阱和缺陷》void (*signal(int , void(*)(int)))(int)的深刻解读
猜你喜欢

Simple use of xftp

The most complete difference between sizeof and strlen, as well as pointer and array operation analysis
![[Quick MSP430f149] Notes on learning MSP430f149 during the game](/img/06/741c609b24be007718091b8348666c.png)
[Quick MSP430f149] Notes on learning MSP430f149 during the game

This beta version of Typora is expired, please download and install a newer; workaround

虚拟机栈帧结构
![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]

VsCode打开终端的方法
![[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]

C语言,库函数中qsort的用法,及解释

VSCode隐藏左边活动栏
随机推荐
Delete all files containing a keyword in the current path
Written before the official account - QT, ARM, DSP, microcontroller, power electronics and transmission!
[Quick MSP430f149] Notes on learning MSP430f149 during the game
Comparison of advantages and disadvantages of VsCode and Sublime editors
Antd简单启动一个企业级项目
查找Proj4js地图投影参数
多层板的层数,为啥选项都是偶数?就不能选奇数?
自定义类加载器
【部分项目展示】
NS3报错 fatal error: ns3/opengym-module.h: No such file or directory
---------手撕二叉树,完成二叉树的前中后序遍历,以及前中后序查找
clinit方法
VsCode与Sublime编辑器优缺点对比
This beta version of Typora is expired, please download and install a newer;解决方法
[Punctuality Atom] Learning and use of IIC (unfinished...)
工程师必看:常见的PCB检测方法有哪些?
Insertion Sort in Classic Sort
Kunlun state screen production (serial 3) - based article (button serial port to send)
牛顿迭代法求方程的根
"R Language + Remote Sensing" Comprehensive Evaluation Method of Water Environment