-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path1079.c
59 lines (56 loc) · 1.2 KB
/
1079.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#include<stdlib.h>
#include<stdio.h>
#include<string.h>
int main()
{
char data[128];
char *tmp=NULL;
int sum,prekey,currkey;
while(scanf("%s",data)==1)
{
sum=0;
prekey=-1;
tmp=data;
while(*tmp!='\0')
{
if(*tmp>'v')
{
if(*tmp=='z')
{
currkey=7;
sum+=4;
}
else
{
currkey=((*tmp-'a')-1)/3;
sum+=((*tmp-'a')-1)%3+1;
}
}
else if(*tmp>'s')
{
currkey=(*tmp-'a'-1)/3;
sum+=((*tmp-'a')-1)%3+1;
}
else
{
if(*tmp=='s')
{
currkey=5;
sum+=4;
}
else
{
currkey=(*tmp-'a')/3;
sum+=(*tmp-'a')%3+1;
}
}
if(currkey!=prekey)
prekey=currkey;
else
sum+=2;
tmp++;
}
printf("%d\n",sum);
}
return 0;
}