#include <stdio.h>
char a[100009];
int main()
{
int n=0;
int sum=0;
scanf("%[^\n]s",a);
while(a[n]!=0){
if(a[n]==32){
sum+=1;
}
else if(a[n]>='a'&&a[n]<='o')
{
if((a[n]-96)%3==1){
sum+=1;
}
else if((a[n]-96)%3==2){
sum+=2;
}
else if((a[n]-96)%3==0){
sum+=3;
}
}
else if(a[n]>='p'&&a[n]<='s')
{
sum+=a[n]-'p'+1;
}
else if(a[n]>='t'&&a[n]<='v')
{
sum+=a[n]-'t'+1;
}
else if(a[n]>='w'&&a[n]<='z')
{
sum+=a[n]-'w'+1;
}
n++;
}
printf("%d\n",sum);
return 0;
}
swust oj1185:手机打字
这是一个C语言程序,主要功能是对输入的字符串进行处理。它统计了空格的数量,并对特定字母范围内的字符执行特定的加法操作。程序对小写字母执行与3的模运算,并根据结果增加相应的计数。对于特定范围的大写字母,程序直接将字母转换为其在该范围内的相对位置值并累加。最后输出总和。
摘要由CSDN通过智能技术生成