-
-
chen0596cong
丨Lv 4
#include "iostream"using namespace std;int letter[28]={1,3,5,1,3,5,1,3,5,1,3,5,1,3,5,1,3,5,7,1,3,5,1,3,5,7,1,0}; // a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,zint main(){char *start,*next;char str[100];int sum = 0;while(cin>>str){ start = str; next = str+1; while(*start != '\0') { while((*next - *start == 1&&letter[*next - 'a']-letter[*start - 'a']==2)||(*next - *start == 2&&letter[*next - 'a']-letter[*start - 'a']==4)||(*next - *start == 3&&letter[*next - 'a']-letter[*start - 'a']==6)) //ab abc bc ac wz { start = next; next++; } /***********************************/ /**/if((*next - *start == -1&&letter[*next - 'a']-letter[*start - 'a']==-2)||(*next - *start == -2&&letter[*next - 'a']-letter[*start - 'a']==-4)||(*next - *start == -3&&letter[*next - 'a']-letter[*start - 'a']==-6)) /**/{ /**/ sum++;//按下c之后,下一个字母a,要不要等1秒,不要的话请注释这行 /**/} /**/else /**/ sum++;//按下c之后,下一个字母d,要不要等1秒,不要的话请注释这行 /***********************************/ sum+=letter[*start - 'a']; start = next; next++; } /***********************************/ /**/sum = sum - 1;//以上两行sum++都注释了的话,请注释这行 /***********************************/ cout<<sum<<endl; sum = 0;}return 1;}