当前位置:网站首页>测试第一题
测试第一题
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
-------------------边栏推荐
- The IEEE under the specified journal search related papers
- openssl 1.1.1 compile statement
- VsCode connects to the remote server and modifies the file code
- 【已解决:el-input标签无法输入或不显示文字】
- 2020-09-03 Solve the very slow installation of pip install [Errno 101] Network unreachable problem
- i++与 ++i 的区别
- -----博客声明
- openssl1.1.1ARM dual compilation
- xxx is not in the sudoers file.This incident will be reported error
- ES6语法笔记(ES6~ES11)
猜你喜欢

xftp的简单使用
![[Quick MSP430f149] Notes on learning MSP430f149 during the game](/img/06/741c609b24be007718091b8348666c.png)
[Quick MSP430f149] Notes on learning MSP430f149 during the game

三种内核结构---宏内核、微内核、混合内核

IEEE在指定期刊下搜索相关论文

How to open terminal in VsCode

VSCode隐藏左边活动栏

【markdown常用用法】

主机和从机配置,建立ssh连接实现Rviz远程控制

Kunlun state screen production (serial 3) - based article (button serial port to send)

VSCode hides the left activity bar
随机推荐
Real-time waveform display of CAN communication data based on QT (serial eight) ==== "Sub function or new class calls ui control"
【江科大自化协stm32F103c8t6】笔记之【入门32单片机及GPIO初始化参数配置】
顺序二叉树---实现数组的二叉树前序遍历输出
Vim查找字符
this的指向问题
【正点原子】IIC的学习与使用(未完...)
ipconfig Command Guide
三种内核结构---宏内核、微内核、混合内核
C语言,库函数中qsort的用法,及解释
多层板的层数,为啥选项都是偶数?就不能选奇数?
【正点原子】sys.c、sys.h位带操作的简单应用
删除当前路径下含某个关键字的所有文件
VsCode连接远程服务器并修改文件代码
This beta version of Typora is expired, please download and install a newer;解决方法
Insert map data efficiently
无法完成包的安装npm ERR! Refusing to install package with name “moment“ under a package also called “moment“
服务器基础知识:包含基本概念,作用,服务器选择,服务器管理等(学习来自米拓建站)
c语言编程练习
Kunlun state screen production (serial 3) - based article (button serial port to send)
ES6语法笔记(ES6~ES11)